I am getting following error when I am running sudo ionic build android
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.
I have unzipped android-sdk inside '/opt'.android command runs fine from terminal.
I am setting my $ANDROID_HOME in ~/.bashrc
export ANDROID_HOME="/opt"
export PATH=$PATH:$ANDROID_HOME
export PATH=$PATH:/opt/platform-tools
export PATH=$PATH:/opt/tools
echo $ANDROID_HOME gives /opt.
echo $PATH gives /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/arvind/workspace:/opt:/opt/platform-tools:/opt/tools
P.S.: Running android from terminal gives following warning.( Don't know if it matters ).
(Android SDK Manager:6041): IBUS-WARNING **: The owner of /home/user1/.config/ibus/bus is not root!
If you have installed ionic globally(use sudo npm install -g ionic), you should not add sudo when you use ionic cli command. Just use:
ionic platform rm android
ionic platform add android
ionic build android
Hope this will help you, regards!
you just have to point out the bin directory inside android studio as:
inside ~/.bashrc
export ANDROID_HOME=/path/to/android-studio/
export PATH=$PATH:$ANDROID_HOME/bin
now echo $PATH and make sure the android studio is included in the path.
Related
I had set create .bash_profile file and save these lines:
export ANDROID_HOME=/Users/macbookpro/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
and then enter in terminal: source ~/.bash_profile
and if I enter in terminal this command: echo $ANDROID_HOME
I have the correct path:
/Users/macbookpro/Library/Android/sdk
but If I run command:
ionic cordova run android
in my ionic project, I got this error:
ERROR running one or more of the platforms: Android SDK not found. Make
sure that it is installed. If it is not at the default location, set
the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project
what should I do!
I am facing a problem whan I am running command:
$ ionic build android
The output is:
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.
My .bashrc file :
export ANDROID_HOME=/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools
export PATH=$PATH:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/build-tools/23.0.1
Echo $path command:
$ echo $PATH
/home/harishrathor/bin:/home/harishrathor/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/local/jdk1.8.0_74/bin:/home/harishrathor/.config/composer/vendor/bin:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/23.0.1
Echo $ANDROID_HOME is:
$ echo $ANDROID_HOME
/home/harishrathor/Desktop/IonicApp/android-sdk-linux
Above $PATH and $ANDROID_HOME outputs are from application directory.
From $HOME directory the output is:
$ echo $ANDROID_HOME
/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/android
And the android-sdk-linux is located in the given directory. But it is still showing this error. Someone, please help me.
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.
while running cordova build from my app directory i get following 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.]
ERROR building one of the platforms: Error: /home/shakir/Documents/myapp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/shakir/Documents/myapp/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
I have set my ~/.profile file as follows
export ANDROID_HOME="/usr/local/android-sdk-linux"
export ANDROID_PLATFORM_TOOLS="/usr/local/android-sdk-linux/platform-tools"
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS
and echo ANDROID_HOME give following results
/usr/local/android-sdk-linux
I am using Ubuntu 14.04. How to solve this issue and build cordova apps?
This error occurs, because of you didn't set your android sdk path correctly.
First, find where the android-sdk folder located in your computer. Inside the android-sdk folder, there is a folder called 'platform-tools'. So you can identify android-sdk folder correctly. Then get the path to the android-sdk folder. Now open the terminal and enter following command,
export ANDROID_HOME="your android-sdk path"
Now run the project.
you have probably used "sudo" for adding android platform.. a quick solution for this problem is:
Restore the right folder permission to all the folder/subfolder of the platforms folder
Delete the android platform with sudo cordova platform remove android
Add the android platform with cordova platform add android DON'T USE THE SUDO! If there are errors without the sudo SO that's the problem! NEVER use the sudo thing or the project will have issue like this!
if you still have a problem then you may have installed cordova using sudo, also there is a solution for it:
first we have to set up npm for global installation so we can use it without sudo, the preferred way of enabling npm to install packages globally without breaking out of $HOME is to set a local node prefix. This is as easy as running:
echo prefix = ~/.node >> ~/.npmrc
echo 'export PATH=$HOME/.node/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
then Running:
npm install -g cordova
it may results in:
Error: EACCES, permission denied '/home/yourusername/.config/configstore/update-notifier-cordova.json'
to fix it:
sudo chown yourusername:yourusername /home/yourusername/.config/configstore/update-notifier-cordova.json
After that, you can happily run npm install -g cordova without sudo, without running into permission conflicts and if something is completely broken and you want to start from scratch, all you need to do is remove your ~/.node directory.
Hope this help!
you can also look at these two links: source 1&2
Run following command in terminal :
export
PATH=${PATH}:/Users/Document/Android-sdk/tools:/Users/Documents/Android-sdk/platform-tools
You may also get this Error
Error: EACCES: permission denied, open '/home/yourusername/.cordova/lib/npm_cache/cordova-android/5.1.1/package/.npmignore'
to fix it use this command
sudo chown -R yourusername:yourusername /home/{username}/.cordova/lib/npm_cache/cordova-android/5.1.1/package
UPDATE 1:
This was everything I did in the end:
sudo aptitude install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo aptitude update
sudo aptitude install nodejs
sudo aptitude install npm
sudo npm install -g cordova
sudo npm install -g phonegap
phonegap create my-app
cd my-app
export PATH=${PATH}:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/tools
sudo aptitude install ant
cordova platform add android
android create avd --name my_and --target 1
phonegap run android
Was any of that not neccessary?
ORIGINAL QUESTION:
On my Ubuntu 12.04 computer, I've just installed node.js with npm and cordova:
$ node -v
v0.10.23
$ npm -v
1.3.17
$ cordova -v
3.3.0-0.1.1
When I try to add android:
$ cordova platform add android
I get the following output:
Creating android project...
/usr/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Anyone know why this is happening and how to resolve it?
I get the same issue with PhoneGap.
It's possible that the Android tools binaries are not in your path.
According to the PhoneGap docs (http://docs.phonegap.com/en/2.9.0/guide_getting-started_android_index.md.html), you need to include the Android SDK's tools and platform-tools in your PATH environment variable.
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
where Development is the path you installed your SDK.
Run the "android" command from your adt\sdk\tools folder and install the latest Tools and SDK. Also make sure your PATH has the right variables.
For this you will need ANT to be installed , a JAVA JDK and an Android SDK installed
JAVA_HOME (C:\Program Files\Java\jdk)
ANT_HOME ({ant location}\apache\apache-ant)
ANDROID_HOME ({android sdk location}\android-sdk)
Add these to your PATH variable like %ANT_HOME%/bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin
Close and re-open your cmd and run your command again.
I'm running Ubuntu 12.04 and was having the same problem as you until a few minutes ago.
The two things I've noted that I had missed during installation:
The Android version should be 19 and you should be able to type 'android' at the console and see some output or see a window pop-up. Make sure that you add the path to the folder where android.jar is located to your PATH variable, and set ANDROID_HOME to that same path as well. Typically, you would do this in your .bashrc file or in /etc/environment If you edit either of these files, you'll need to either 'source ~/.bashrc' or reopen your terminal to force it to reload the file. Type 'android' to make sure its working.
I observed that the cordova setup script was attempting to write files into a subdirectory 'add-ons' of the Android SDK. That directory does not exist in the Android 19 distribution itself. Consequently, I created it manually and made it writeable by my user account.
ex: Android distribution path:
/opt/android/
The path that its trying to write to:
/opt/android/sdk/add-ons
Once I had done that I was able to get past the problem you've noted above.
It looks like the cordova andorid library file corrupted in your home directory.
Try to remove home//.cordova directory and do this again cordova platform add android in your cordova project.
Make sure you have sourced /platform-tools and /tools to PATH.
Android
The Android command-line tools are built upon shell scripts. You must have the Android SDK's tools and platform-tools folders in your PATH!
Create a project
Run the create command with the following parameters:
Path to your new Cordova Android project
Package name, following reverse-domain style convention
Main Activity name
$ /path/to/cordova-android/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
It looks like this error could also be caused by the absence of a compatible Android SDK version (at the moment 4.2).
I use cordova.
2days I have same problem"java,ant,android,cordova,command test is ok,
but run cordova platform add android show me Error: An error occurred while listing Android targets".
Now I fixit use:
"chmod 777 ant and android sdk place"
,then it will work.
I use ubuntu 14.04 32bit,
if the problem still exist please make sure that you have the right permissions try
sudo chmo-R 777 /home/your-user-name/.cordova/
Also make sure that you are NOT using sudo to add Android as a platform
This is incorrect in the default Cordova installation
sudo cordova platform add android
Just do
cordova platform add android
I've searched a lot for this, and what worked for me was setting the shell variable $ANDROID_HOME to the path of the sdk/ folder in my adt-bundle directory from android. Use export to do this:
export ANDROID_HOME="/Users/YOUR_USER/Developer/adt-bundle/sdk/"
but be sure to change the directory to match yours.
Good Luck!
Not sure if someone else had a problem with this, but when removed and added my platform again, I realized in my config.xml I had <icon src='...'> and the path inside the src was wrong.
Here was the error output I received when I added the platform again:cp: no such file or directory: C:\Users\{pathtofile}.png.
After I fixed the path, it worked fine.
It can be that your cordova installation have been corrupted try to remove your .cordova folder "rm -R ~/.cordova"
And "run cordova platform add android" again
I have built a Phonegap app and am now trying to integrate it with Phonegap Build. I'm following the very simple guide here.
So I am doing:
sudo npm install -g phonegap
sudo phonegap create hello com.example.hello HelloWorld
cd hello
sudo phonegap local build android
The last command results in the error:
The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: /bin/sh: 1: android: not found
I then did:
which android
with the result:
/home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
which is the corrent path.
The phonegap version is 3.1.0-0.15.0.
Any ideas why I am getting this error?
Edit
If I run:
sudo phonegap local build /home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
I get yet another error:
/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141
platformPath = path.join('.', 'platforms', platform.local);
^
TypeError: Cannot read property 'local' of undefined
at LocalBuildCommand.module.exports.addPlatform (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141:60)
at LocalBuildCommand.execute (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:95:32)
at LocalBuildCommand.run (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:70:10)
at Object.build (/usr/local/lib/node_modules/phonegap/lib/phonegap/util/command.js:28:25)
at CLI.module.exports (/usr/local/lib/node_modules/phonegap/lib/cli/local.build.js:34:20)
at CLI.module.exports [as argv] (/usr/local/lib/node_modules/phonegap/lib/cli/argv.js:66:17)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/bin/phonegap.js:24:21)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
Laters version of android sdk moved adb to platform-tools. Try to include both tools and platform-tools in your path. see
~/Tools/adt-bundle-linux-x86_64-20131030/sdk $ cat tools/adb_has_moved.txt
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK, launch the SDK and AVD
Manager (execute the android tool) and install "Android SDK
Platform-tools"
Please also update your PATH environment variable to include the
platform-tools/ directory, so you can execute adb from any location.
I use following export commands.
export ANDROID_BUNDLE_HOME="$ATILLA_TOOLS/adt-bundle-linux-x86_64-20131030"
export ANDROID_SDK_HOME="$ANDROID_BUNDLE_HOME/sdk"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
export PATH=$PATH:$ANDROID_SDK_HOME/tools
export PATH=$PATH:$ANDROID_SDK_HOME/platform-tools
both adb and android should work in command line. Also try to use
phonegap local build android
without sudo.
see following example
$phonegap create deneme1
[phonegap] created project at /home/atilla/Projects/Denemeler/a/deneme1
$cd deneme1/
$phonegap local build android
[phonegap] adding the Android platform...
[phonegap] compiling
Android... [phonegap] successfully compiled Android app
After this successful message try to find your platform and apk file.
$ls -al platforms/
$ls -al platforms/android/
$ls -al platforms/android/bin
you should see HelloWorld-debug.apk in this directory.
-rw-r--r-- 1 atilla atilla 1542462 Ara 5 14:31 HelloWorld-debug.apk
install the phonegap npm global package with sudo, it's ok.
But then you should run phonegap with your own user
sudo npm install -g phonegap
phonegap create hello com.example.hello HelloWorld
phonegap local build android
executing with sudo you are switching to root user therefore environment variables as $PATH are not necessarily the same.
Try to Add your Android Path to your PATH Enviroment Variables.
if you use Linux, first try:
echo $PATH
This command display your PATH variable, search the Android path on this.
If you don't see the android path, you need to add that path on your enviroment variable.
Try this:
echo 'export PATH=$PATH:/home/user/mis_prog' >> /home/user/.bashrc
You must edit the configuration file of your login shell.
As usually the BASH shell is the most used, you must edit your /home/user/.bashrc.
For this you will use a text editor or just a command to make the task easier.
If you use some Windows Version, you can edith the enviroment variable PATH from system propertyes, something like this: http://www.computerhope.com/issues/ch000549.htm