0

I have a phonegap created for iOS, and I want to build it for Android, but the following commands would not convert it to an Android project:

phonegap platform update android
phonegap install android
phonegap build android

Here is one of the errors that I receive:

lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap platform update android
[phonegap] updating Android platform...
   [error] Platform "android" is not installed.
lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap install android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
   [error] The provided path "/home/lucas/Dropbox/projects/ecostartup/ecometrix-app/platforms/android" is not an Android project.

Here is another error:

lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap build android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
   [error] An error occured during creation of android sub-project. 

/home/lucas/.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/lucas/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ 

And here is some project info:

lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls
platforms  plugins  README.md  www
lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls platforms/
ios

How can I convert this to Android?

modulitos
  • 14,737
  • 16
  • 67
  • 110

2 Answers2

2

actually looking at your logs, it seems that the app has been built. The only visible error is that no phone was detected and the emulator could not be started.

About the commands you use :

  • phonegap platform update android this one is for when you already added android platform to your project and installed a newer version of phonegap so you don't need it for the moment
  • phonegap install android here you're trying to install your app to a device connected to your computer with proper drivers installed and debuging allowed
  • phonegap build android here you go, this is the good command to build the android project and generate a debug apk.

Once you run build, you should find the debug apk in platforms/android/bin

If you use some plugins, also check that they are compatible with android.

QuickFix
  • 11,661
  • 2
  • 38
  • 50
0

I double checked to make sure that Android was on my path:

lucas@lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app/platforms$ echo $PATH
(rest of path)...:/opt/android-sdk-linux/sdk/tools:/opt/android-sdk-linux/sdk/platform-tools

But I needed to install Cordova:

sudo npm install -g cordova

and I ran phonegap build android, which gave me another error to install Ant:

sudo apt-get install ant

This was all after installing nodejs, npm, and phonegap.

I found this post very helpful:

PhoneGap/Cordova Android Development

(it just took me a while to find it)

Community
  • 1
  • 1
modulitos
  • 14,737
  • 16
  • 67
  • 110