cordova phonegap - error installing on Android platform - android

I am new to Cordova and phonegap but have Android working on my ubuntu 12.04.
I followed this official guide and manage to install cordova.
Despite my machine supports android sdk, when I run this command:
cordova platform add android
I get the following exception:
*cordova platform add android
Creating android project...
/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112: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)
root#sergio-Aspire-5755G:/home/sergio/Development/HelloWorld# cordova platforms ls
Installed platforms:
Available platforms: android, blackberry10, firefoxos, ubuntu
root#xxx-Aspire-5755G:/home/sergio/Development/HelloWorld# cordova platform add android
Creating android project...
/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112: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 tried and see other post like this but noone helped me.
Android sdk version 19 is installed

1) run "android avd" command and create at least one virtual device based on a version of a previously downloaded SDK.
2) sudo apt-get install ant1.8
worked for me.

You need to check if path to Android SDK is correct or not. Check your Environment Variables PATH, ANDROID_PLATFORM_TOOLS, ANDROID_HOME, ANT_HOME you can check if they are configured correctly by echo %ANDROID_HOME% check for all Paths you will know which path is not configured properly.

I solved this way:
adding the below line to my .bashrc:
export PATH=$PATH:/opt/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/opt/adt-bun‌​dle-linux-x86_64-20131030/sdk/tools

Related

Cordova build issue in ubuntu

I was following the tutorials # http://www.gaggl.com/2014/04/apache-cordova-development-environment-install-on-ubuntu/
Cordova build is failing with message:
:~/projects/Hello$ sudo cordova build
Running command: /home/skn/projects/Hello/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/skn/projects/Hello/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/skn/projects/Hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I have included the android in the path variable also.
skn#bangre:~/projects/Hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin/java:/usr/bin/ant:.:/home/skn/android-sdk-linux/tools:/home/skn/android-sdk-linux/platform-tools
From screenshot below you can see the sdk is installed
Also I have the following check which is passing.
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./android_sdk_version
21
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./check_reqs
Looks like your environment fully supports cordova-android development!
Please help me point out the issue.
yes turns out the cordova node.js scripts assumes the android sdk directory name as 'android-sdk' , for ubuntu when we unzip we get 'android-linux-sdk'

Running Cordova HelloWorld project on Ubuntu

I've worked with Apache Cordova quite a bit on Windows but for some reason I can't get the project to run on Ubuntu.
I've setup the Android SDK correctly so adb and android both run from Terminal.
Here's the output I get when attempting to run the project on android.
josh#josh-ubuntu:~/Projects/hello$ cordova run android
Running command: /home/josh/Projects/hello/platforms/android/cordova/run
/home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error: EACCES, permission denied '/usr/local/bin/android-sdk-linux/tools/lib/build.template'
at Object.fs.openSync (fs.js:438:18)
at Object.fs.readFileSync (fs.js:289:15)
at /home/josh/Projects/hello/platforms/android/cordova/lib/build.js:120:40
at _fulfilled (/home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:760:13)
at /home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:574:44
at flush (/home/josh/Projects/hello/platforms/android/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /home/josh/Projects/hello/platforms/android/cordova/run: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Could it be something wrong with my file permissions?
The log is saying that is a Permissions Problem!
Try to execute
sudo cordova run android
and if it lets you, then for sure it's a permission issue!

Adding android platform to a Ionic (Cordova) + Genymotion project in Ubuntu 14.04

Here are my configurations:
OS: Ubuntu 14.04
Genymotion: 2.3.0
node: v0.10.25
npm: 1.3.10
cordova: 3.6.3-0.2.13
ionic: 1.2.7
After I created an Ionic project I tried adding the Android platform to it:
$ ionic start myApp sidemenu
...
$ cd myApp
$ ionic platform add android
Creating android project...
/home/mehran/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
throw e;
^
Error: Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.
at /home/mehran/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:43:27
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Error: /home/mehran/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135: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)
The problem is that there's no android in the installed Genymotion folder. Am I supposed to install the original android SDK as well?
It's mention worthy that the installed Genymotion starts the emulated android on its own perfectly.
Yes you have to install the Android SDK. You can find it here: http://developer.android.com/sdk/index.html
You also need to add the tools folder into your PATH. So that it can run the android command
Export it like this:
export PATH=$PATH:<PATH_TO_ANDROID_SDK>/tools
Replace <PATH_TO_ANDROID_SDK> with the absolute path to your Android SDK.
before adding the android platform, you need you install the Android SDK. The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.
In case you already installed the SDK try to update it to the latest version of the Android SDK Tools.

Issues with cordova and android studio

I have downloaded android studio, installed ant, node.js, cordova and jdk
But I can not add platform to my cordova android app
Here is the bashrc file:
JAVA_HOME=/usr/lib/jvm/jdk1.8.0
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
export PATH=${PATH}:/home/Dev/android-studio/sdk/tools
export PATH=${PATH}:/home/Dev/android-studio/sdk/platform-tools
Whenever I try to add platform under my created app project it throws error:
Creating android project...
/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/lib/check_reqs.js:87:29
at _rejected (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:808:24)
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:834:30
at Promise.when (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:752:41)
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:574:44
at flush (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
I an tired of searching all the answers in stackoverflow and google. Not a single guide could solve my problem. Just one thing I want to use ANdroid studio, not eclipse. SO please do not mention eclipse workarounds. If there is any clean install method , please mention if needed.
I had a similar issue - if you have eclipse installed prior your cordova installation, then you probably don't have the latest API updates.
Run android from your command line to open your SDK Manager - or find it in your android installation root folder (for CLI - Use Administrator) - or simply from your eclipse UI command.
In here find where updates are needed and install and run your android installation as you did before cordova platform add android

PhoneGap install on Mac

I'm getting a bit annoyed at this install. I've followed the instructions from here and I've got as far as adding Android as a platform, the large chunk of code is a copy and paste from my Terminal when I am trying to run it. I have Android SDK installed at ~/Development/sdk/ ~ is the home directory for the user
Donalds-MacBook-Air:hello donaldsutherland$ cordova platform add android
Creating android project...
/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Donalds-MacBook-Air:hello donaldsutherland$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/your-path/android-sdk-linux/platform-tools:/your-path/android-sdk-linux/tools:/Development/android-sdk-linux/platform-tools:/Development/android-sdk-linux/tools:/Development/sdk/platform-tools:/Development/sdk/tools
Donalds-MacBook-Air:hello donaldsutherland$
If I run $ cordova platforms ls it lists Available platforms: amazon-fireos, android, blackberry10, firefoxos, ios
create a a profile file ~/.bash_profile
write this line to add the android SDK folder to your PATH
export PATH=${PATH}:~/Development/sdk/tools:~/Development/sdk/platform-tools
close the terminal and open it again, then it should recognize the "android" command everywhere

Categories

Resources