Environment variable issue in build an apk in ionic project - ionic2

I am trying to build an apk in ionic 2 but while building is getting following error.
Error:
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
After that, I set the environment variable and path. Even though still am getting that error again can anyone please help me how to solve this issue

Instruction 1:
After adding your ANDROID_HOME, make sure you do the below:
Restart your System or run source ~/.bash_profile
Remove Android platform from your project ionic cordova platform rm android or ionic platform rm android
Add Android platform ionic cordova platform add android
Then ionic cordova run android or ionic run android
Instruction 2:
To set your ANDROID_HOME and JAVA_HOME, follow the below steps:
Run command open ~/.bash_profile
Paste the below in the file that opens on your Text editor
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Save - "Command S" or "Ctrl S"
Then Follow the "Instruction 1:" above
NOTE: Make sure you have 24.4.1_1 SDK
Hope this helps.

Related

Ionic2: Package com.my.app has no certificates at entry AndroidManifest.xml

I created one application using Ionic2 and when i run the command ionic cordova run android --prod --release I am getting an error
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl
971492117.tmp/base.apk has no certificates at entry AndroidManifest.xml]
Do anyone know how to fix this error?
NB: I have seen similar questions all of them are for native application development.
You cannot install a package build with --release without signing it. See this question on Ionic Forum
Try ionic cordova run android --prod to install an unsigned app to your phone.
Probably you have another app installed with the same name, signed with another type of key. Ie in your device you the app singed with a release key. Other possibility is there is an app in your device with a newer version.

Install specific version of Cordova CLI in Visual Studio 2017

I need to do some updates to a Cordova app created using Visual Studio 2017 Tools for Apache Cordova (TACO).
The Cordova CLI version listed in the config.xml file is 6.3.1 and the cordova-ios platform version is 4.2.0
When I try to build the project (using a Mac with XCode 8.3.3, I get this error
Build failed with error Remotebuild requires your projects to use
cordova-ios 4.3.0 or greater with XCode 8.3. Please update your
cordova-ios version.
I don't see any updates to TACO in VS2017 or instructions in the Microsoft documentation for Apache Cordova Tools.
Ideally, I'd like to make the most minor version update possible to get my build working with XCode 8.3.3.
I know there is a Cordova version 7.0.1, but I don't want to make that upgrade just yet because I'm under the gun time wise.
I don't see any updates to TACO in VS2017 or instructions in the Microsoft documentation for Apache Cordova Tools.
You can follow below steps to use the latest cordova-ios:
Open config.xml with designer
Toolset->Check the checkbox of Take latest patch(requires internet) on cordova-ios row.
Update:
If you don't see the checkbox in the designer page, you need to change it in the xml. Find the following tag in config.xml:
<engine name="ios" spec="4.2.0" />
and modify it to:
<engine name="ios" spec="~4.2.0" />
Update2:
If the version is still not update to the latest, please try the below steps to fix the issue:
Clear the cordova cache under: Tools->Options->Tools for Apache Cordova->Clear Cordova cache.
Open cmd of your project folder;
Type npm install -g cordova-ios to install globally the cordova-ios(requires node installed as pre-work);
Then cordova platform rm ios;
Type cordova platform add ios;
Run your project again
For iOS, please install iOS#4.3.1. This is the only version i found working with XCode 8.3.3
I had the same error, follow this steps :
1- If not installed yet, install Node
2- Install the latest version of cordova or anyother:
npm install -g cordova
3- Install taco-cli:
npm install -g taco-cli
4- Configure taco-cli :
taco remote add ios
(respond a few question, MAC IP, Port,etc...)
5- in your root project add or edit a file named "taco.json", add inside :
{
"cordova-cli": "7.1.0"
}
Where 7.1.0 correspond to your cordova version (cordova --v)
6- Try to emulate on your MAC:
taco emulate ios
You will maybe have an error about platform. Ignore it
7- Close then open Visual Studio
8- On Visual Studio open the config.xml UI EDITOR and change the toolset name with
Global cordova
9- Build using Visual Studio.
If it doesn't work, please let me know
I don't have the authority to add a comment to the answer above, so adding my updates here:
If the version is still not update to the latest, please try the below steps to fix the issue:
First, modify your project config.xml file using an editor, rather than through the tools. Not sure why it was necessary, but this was the key difference from the above instructions. I also found that 4.3.1 was best. Remove any ~ characters before the version.
Then:
Clear the cordova cache under: Tools->Options->Tools for Apache Cordova->Clear Cordova cache.
Open cmd of your project folder
Type npm install -g cordova-ios to install globally the cordova-ios(requires node installed as pre-work)
Then cordova platform rm ios
Type cordova platform add ios
Run your project again
If the cordova command in steps 4 and 5 doesn't work, add the cordova bin directory to you path. In my case
C:\ProgramData\Microsoft\VisualStudio\MDA\ad0a0856\taco-toolset-6.3.1\node_modules.bin\

Ionic can't find ANDROID_HOME on Windows 10

Im using Ionic to build an Android app and I'm finding a problem that I cant work around or find an answer to. When I run ionic build android or ionic emulate android I get the following:
Error: Failed do find 'ANDROID_HOME'...
I believe I have added the correct variables to PATH and ANDROID_HOME under System Variables, but please check: http://imgur.com/a/UOdCd
The first image is ANDROID_HOME, the second shows where the sdk is located, the third is the Error itself and the fourth is my path variable.
I run it from Git Bash. Running as an administrator did not make any difference, I also tried reinstalling Android SDK (with Android Studio) in a different folder (was in %HOME%\AppData\Local\Android\ before) without any difference. Also tried to reboot after reinstalling SDK.
I also tried to run the SDK Manager first (C:\Android\sdk\tools\android.bat) and keeping it open while trying to build or emulate, but it still didn't work.
You need to create a new system variable called ANDROID_HOME and as a value put the path to the android SDK installation directory.
For more information, please refer to the installation guide.

ESLint in WebStorm

Has anybody encountered the problem ESLint not loading in WebStorm? I'm trying to specify a path /usr/local/bin/eslint, /usr/local/bin,
Every time I got this message:
or no such directory message.
You need to point that field to the actual ESLint script. This would usually be the place where you've installed the ESLint npm package or command-line tool.
OS X El Capitan
I've installed npm & node with brew. It's easy to keep stuff up to date with brew.
brew install node
then installed eslint globally with npm
npm i eslint -g
and here is my working config:
/usr/local/bin/node /usr/local/lib/node_modules/eslint
I add .eslintrc file with eslint rules in project's root folder.
Try using those drop-downs next to input field, webstorm gives path w/o any typing.
Following are the steps you need to get it working on Windows 10:
Open command prompt and navigate to your project root.
Run the following command:
npm install eslint --save-dev
Once ESLint finishes installing in the above step, navigate through the following menus in Webstorm:
File > Settings.... Click on Settings...
In the Settings screen that shows up, in the top-left hand corner, there is a Search box. Type eslint in it.
That will show you the 'ESLint' settings for this project. Now tick the checkbox that says "Enable". Make sure that the Node interpreter: has the right value. In my case, it was C:\Program Files\nodejs\node.exe
Just below the Node interpreter: setting, there is a setting called ESLint package:. If you have correctly installed the ESLint package as I mentioned in Step 2 above, this setting will be auto-populated to show the current path of ESLint package from your project's node_modules folder. In my case, the value of this setting was:
D:\www\gdp\node_modules\eslint (gdp is my project root folder)
Click on Apply and OK buttons respectively.
Restart Webstorm. If you have successfully completed all the steps, you will not see the prompt to enter the ESLint again.
Enjoy!!!

iOS Simulator doesn't launch with Calabash

I have Calabash installed as a pod in my project. The gem itself is installed using bundler. When I try to run cucumber for my Calabash target, the first features starts but just hangs and the simulator never launches:
$ bundle exec cucumber
Feature: Ensure Login and Oauth Screen Functionality
Scenario: Verify Welcome Page # features/Sign_in.feature:3
More details from my install:
# xcode installation location
$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
# xcode version
$ xcodebuild -version
Xcode 5.1.1
Build version 5B1008
# calabash version
$ bundle exec calabash-ios version
0.9.168
# calabash < 0.9.169 or Xamarin IDE users
# start your app manually in the simulator or from Xcode and then launch a console
$ bundle exec calabash-ios console
> server_version
{
"outcome" => "SUCCESS",
"app_id" => "[REDACTED]",
"simulator_device" => "iPhone",
"version" => "0.9.168",
"app_name" => "[REDACTED]",
"iphone_app_emulated_on_ipad" => false,
"4inch" => true,
"git" => {
"remote_origin" => "git#github.com:jmoody/calabash-ios-server.git",
"branch" => "master",
"revision" => "adde106"
},
"app_version" => "2.0.1",
"iOS_version" => "7.1",
"system" => "x86_64",
"simulator" => "iPhone Simulator 463.9.41, iPhone OS 7.1 (iPhone Retina (4-inch)/11D167)"
}
Ok,that means calabash cannot locate the your app.
Try this first,
Comment out the APP_BUNDLE_PATH definition on
YourProject/features/support/01_launch.rb like #APP_BUNDLE_PATH =
"~/..../../myApp-cal.app" so The calabash gem can locate the app
automatically.
Open a console go to the project folder from it. Then enter gem install calabash-cucumber this will install the calabash gem its ok to run again even if you installed it previously there's no harm. Then enter calabash-ios setup in that terminal, this will create a calabash target and add the calabash framework to your iOS project. more details about the setup process is mentioned in here.
Now open the project file in xcode editor (You can see the calabash.framework added to your project's framework group successfully.) select the yourApp-cal target and the simulator you want clean, build and run the yourApp-cal target on your simulator.
Then stop it and come back to that console enter calabash-ios console console will start a ruby console that you can work with the app. now (while simulator is on your screen but your app is backbround on that simulator) type start_test_server_in_background your app must come to foreground. If that works the calabash can find and run your app on simulator.
Remember only if you create an app build on a separate folder using a xcodebuild command or script or something, thats the time to set the APP_BUNDLE_PATH variable.
Chathura's answer worked for one of my colleagues, but a couple of us had to find another solution.
The issue for us occurred after introducing CocoaPods. In Xcode, I opened Organizer and noticed we had a derived data folder for the BP (before Pods) project and another for the workspace with Pods. I deleted the derived data folder for the BP project and then everything worked.
I had re-setup calabash before doing this, so the solution in my case may have been a combination of Chathura's answer and mine.