Im trying to build an android app with ionic 2. When I try to run ionic platform add android I get this error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. Failed to find 'android' command in your 'PATH'.
Im using linux mint and already set the environment variables like this:
export ANDROID_HOME=/home/mauro/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When I type android in the console, the sdk manager gets started.
My ionic version is: 2.1.7
and cordova: 6.4.0
Hope anybody can help me with 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
Hope this helps.....
I have the same issue. It seems to be an issue of the combination of cordova, the installed Android SDK version and the profile settings.
This is what worked for me on ubuntu 16.10:
get an older cordova that is known to work:
npm install -g cordova#4.2
(I was on 6.4.0 and 5.0.0)
in .profile:
PATH="~/Android/Sdk/platform-tools:~/Android/Sdk/tools:$PATH"
export ANDROID_HOME=~/Android/Sdk
(Seems you are good there)
I needed the latter to stop the complaining about it even while android was in my path and it also gave me meaningfull errors, which was that API 22 was missing.
Load the profile in current bash:
source ~/.profile
Type android and install SDK 22.
Exit when done and type
ionic build android
and it should work.
Related
I am trying to create a mobile application from my angular app and am using cordova for converting the web app to mobile. I had followed all requirements given on the apache cordova official guide and installed Android studio as well using this online guide.
I had also followed this youtube tutorial which explained to easily convert the angular app into a cordova application using these steps:
- Create a cordova project within the angular project using cordova create <proj_name>
- Create a soft link, adding a link between www folder in cordova project and dist folder of angular project
- Create build
- Add android to cordova project
- Cordova run android
Everything goes fine until cordova run android where it gives me the following error:
Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I checked to see on stackoverflow of any errors and there were in fact a few similar issues, which should have been resolved by editing the ~/.bashrc file and adding:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
However, even after logging out and logging in again, several times, using source ~/.bashrc as well hasn't helped, the same error keeps popping up. I have also installed android studio and checked all paths the Sdk is installed and shows on the Sdk Manager in studio.
If I try to enter android in terminal it gives me an unknown command error, same goes with sdkmanager.
when I run echo $ANDROID_HOME it gives me the correct path:
/home/username/Android/Sdk
when I run cordova requirements it gives me the following:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
android: Command failed with exit code ENOENT
Gradle: installed /opt/gradle/gradle-5.2.1/bin/gradle
Some of requirements check failed
running cordova platform version android in the project gives the following:
form version android
Installed platforms:
android 8.1.0
Available platforms:
browser ^6.0.0
electron ^1.0.0
ios ^5.0.0
osx ^5.0.0
windows ^7.0.0
I do not understand what seems to be missing? I have looked several times but can't seem to find the problem with my installation. Am i doing something naive here?
For anyone facing the same issue: For some reason data was being fetched from npm cache. To clear it, simply:
sudo npm cache clean -f
Maybe not the best approach, but for now it was the only way out
My .bash_profile looks like this
export PATH=$PATH:/Users/subbarao/Library/Android/sdk/platform-tools/
export ANDROID_HOME=/Users/subbarao/Library/Android/sdk/
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
even $(user/libexec/path_helper -s)
When I give ionic platform add android I am getting like this
When I give ionic run android I am running into this error
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /Users/subbarao/Library/Android/sdk/tools/templates/gradle/wrapper
You have cordova-android v 6.1.2. There was an issue with cordova-android. Check this answer.
Try
ionic platform add android#6.2.1
Or
ionic platform add android#latest
Update:
if you are using ionic cli v3, the command is
ionic cordova platform add android#latest
Update SDK and gradle version and then try following commands in the terminal
export ANDROID_HOME=/Applications/ADT/sdk
PATH environment variable
export PATH=$PATH:$ANDROID_HOME/bin
After updating to meteor 1.2, I am not able to get my app to build for android. I have followed the instructions on https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on-Mac to the end.
I get the following error when I run meteor run android-device --verbose :
Getting installed version for platform android in Cordova project
Getting installed version for platform ios in Cordova project
Checking Cordova requirements for platform Android
Your system does not yet seem to fulfill all requirements to build apps for
Android.
Please follow the installation instructions here:
https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on- Mac
Status of the requirements:
✓ Java JDK
✓ Android SDK
✗ Android target: Android SDK not found. Make sure that it is installed. If it
is not at the default location, set the ANDROID_HOME environment variable.
✓ Gradle
I have run rm -rf .meteor/local, export ANDROID_HOME=~/Library/Android/sd, export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-toolsexport ANDROID_HOME=~/Library/Android/sdk, i even set the environment in the server as process.env.ANDROID_HOME = '~/Library/Android/sdk';.
I am not sure how to get this to work, any help will be greatly appreciated.
#junior try giving the complete path of the android sdk...i hope this works...and see if the requirements match...because, it does say all the requirements don't match.....
set ANDROID_HOME=C:\\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
MAC
export ANDROID_HOME="/Users//Library/Android/sdk/"
export ANDROID_TOOLS="/Users//Library/Android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users//Library/Android/sdk/platform- tools"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
and again try re-installing
$ android
and then go to a Cordova-based project directory
$ ionic platform add android
or try this link
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
I'm trying add the android platform to my cordova project, though I get the error:
$ cordova platform add android -d
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Checking Android requirements...
cordova library for "android" already exists. No need to download. Continuing.
Error: An error occurred while listing Android targets
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/lib/check_reqs.js:83:29
at _rejected (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:808:24)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:752:41)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:574:44
at flush (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Without the -d it will be:
Checking Android requirements...
[Error: An error occurred while listing Android targets]
I'm not sure what configuration I am missing. In my ~/.bashrc file I have:
### Java
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export ANDROID_HOME=~/Code/adt-bundle-linux-x86-20131030/sdk/tools
export ANDROID_PLATFORM_TOOLS=~/Code/adt-bundle-linux-x86-20131030/sdk/platform-tools
export PATH=$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH
and I have ant installed:
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
What's missing? Why do i get the error An error occurred while listing Android targets when trying to add the android platform to the cordova project?
Cordova has a script to check if all dependencies are present. Is is called when you run cordova platform add android but unfortunatly it's output is not displayed when it fails.
You can try to run it manually, it should be $home/.cordova/lib/android/cordova/3.5.0/bin/check_reqs
The normal output when everything's fine is "Looks like your environment fully supports cordova-android development!", oterwise it should display a clear message about what's missing.
Maybe your issue is that you havent't installed SDK platform for API 19 in android sdk manager (cordova 3.3 or 3.5 uses target sdk 19).
Update: Cordova 3.3 or 3.5 works on SDK 19 only (Android 4.4.2). The error logs does not mention clearly what platform version it is looking for. Typically error messages are:
Unable to add platform android. Please see console for more info.
or
[Error: An error occurred while listing Android targets]
This can also happen when android (sdk/tools) is not in path. I would have loved if the check-script have printed correct error message. BTW, created a PR for them.
in .bashrc try adding
export ANT_HOME="/usr/bin/ant"
export PATH="$PATH:$ANT_HOME/bin"
export HOME="/home/username"
export ANDROID_HOME="$HOME/android-bundle/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
or try explicitly define the paths globally.
from the terminal I type:
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/tools
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/platform-tools
(rememebr to replace with your own sdk path)
If this doesn't work, try updating the sdk
Please Refer the Question
An error occurred while listing Android targets
and the Link
developer.android.com/tools/devices/managing-avds-cmdline.html
Most probably the path variable pointing to this android was wrong. I had used %ANDROID_HOME% as variable and scaled the same to path variables %ANDROID_HOME%\SDK\TOOLS. This method doesn't work. Experimentally resolved by directly pointing to the Tools and Platform Tools.
Just based on what I did and it worked for me. Hope You get the Issue resolved
I had faced the Issue even after the Cordova check_reqs was working correctly without providing any error.But on adding a new platform this error was still being raised. The above method personaly resolved my issue.
I solved the problem giving full permission for my app folder
$ sudo chmod -R 777 myApp
After that, try again
$ cd myApp
$ ionic platform android
I have an issue with setting up an Android Project on Mac OS.
with the command:
$cordova platform add /path/to/androidSDK/android
I've got the error message:
[Error: Platform "/path/to/androidSDK/android" not recognized as core cordova platform.]
Does anyone have the same Issue ? How can I fix that ?
latest Android SDK version (downloaded today).
Phonegap version: 3.1.0-0.15.0
OSX 10.9 Mavericks
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
Hope this will help you.
this is documentation Phonegab docs
and my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
visit the solution here
I hope this helps you