Reputation: 923
On Linux Mint 17.1 x86_64, Cordova v4.3.0 gives this error:
$ cordova run android
Running command: /home/naman/test/platforms/android/cordova/run
WARNING : No target specified, deploying to emulator
WARNING : no emulator specified, defaulting to Sample
Waiting for emulator...
Booting up emulator (this may take a while)....BOOT COMPLETE
/home/naman/test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error: ENOENT, no such file or directory '/opt/software/android-sdk/tools/tools/lib/build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at /home/naman/test/platforms/android/cordova/lib/build.js:129:40
at _fulfilled (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:760:13)
at /home/naman/test/platforms/android/cordova/node_modules/q/q.js:574:44
at flush (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
ERROR running one or more of the platforms: Error: /home/naman/test/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
PATH variable seems to be alright (the path for SDK is correct):
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/software/android-sdk/tools:/opt/software/android-sdk/platform-tools
I installed it using :
sudo apt-add-repository ppa:cordova-ubuntu/ppa
sudo apt-get update
sudo apt-get install cordova-cli
npm install -g cordova
The installation went smoothly and the project was created without any error. Am I missing some dependency?
Upvotes: 12
Views: 53093
Reputation: 3611
If you are having issues on Ubuntu, you may want to try installing the following packages, per the docs:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
You may also need to install this package:
sudo apt-get install lib32z1
Upvotes: 0
Reputation: 22394
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140321/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
then cordova run android works
Upvotes: 0
Reputation: 602
I had the same error building the android platform, and no solution given here could help me. I decided to run the gradlew command shown by cordova, and saw there was a problem with a png file included in the cordova project. After removing it, I managed building the platform again.
Upvotes: 0
Reputation: 939
I got a same error my solution is underlying.
reeboot and command adb device again : result device showing. then tried again 3. ionic run adnroid --device "OK";
Upvotes: 1
Reputation: 907
For others having this problem, assuming you have already checked and fixed any environment variables using @Naman Dixit's answer, you may also have to remove and add your platforms:
cmd: cordova platform rm [platform(s) of interest]
delete everything in the [yourproject]/platforms folder. Then:
cmd: cordova platform add [platform(s) of interest]
that was the final step I needed to get everything to work
Upvotes: 12
Reputation: 580
You may need to uninstall the existing app on your device.
I installed my app on that device from another computer. When I run cordova run android
I get
You may not have the required environment or OS to run this project
.
But when I try to install my apk by adb
it told my that the app was already installed. So I uninstalled it an it worked.
Upvotes: 18
Reputation: 3526
This is just to have one more reason for this error documented here and for them who are still searching for solution.
When I came accross this error, I tried almost all the solutions listed on the stackoverflow
.
My issue was my device was not getting detected by adb
, adb kill-server/start-server
also not helped me, ***
but changing
USB
port helped.
Upvotes: 1
Reputation: 2616
I got this error after installing the Crosswalk plugin. To solve it I installed the latest Android SDK, deleted the android folder under platforms and ran
phonegap build android
alternatively
cordova platform add --save android
cordova build android
and it was all good.
Upvotes: 0
Reputation: 1896
Happens when platform is added without internet connection.
Ensure internet is OK and type :
cordova platform remove blackberry10
cordova platform add blackberry10
Try to build and run :
cordova run
Hope this fix your problem, also for other platform
Upvotes: 0
Reputation: 5381
I encountered this issue now too. The problem in my case is that the ant.properties file that I'm using is pointed to wrong and NOT existing file.
key.store=D:/Fedmich/_keys/android.keystore
After correcting it, I was able to compile a release apk. Hope this helps someone in the future. Just be sure to read the error_logs that is given in the command prompt.
Upvotes: 1
Reputation: 923
Make sure you have proper environment variables defined (add this in .bash_login
or .profile
and do source .profile
):
export ANDROID_SDK="/opt/software/android-sdk"
export ANDROID_NDK="/opt/software/android-ndk"
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools"
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS"
Upvotes: 8
Reputation: 4278
Your android sdk doesn't seem to be properly installed or you didn't install the proper android sdk version that has the dependency that you seem to be missing
/opt/software/android-sdk/tools/tools/lib/build.template
Upvotes: 3