How to use Phonegap with Android Studio 0.5.4?

Can someone tell me how to get Android Studio 0.5.x to correctly import and build a PhoneGap project?

I have successfully installed JDK SE 1.8.0, Ant 1.9.3, PhoneGap 3.4.0 and Android Studio 0.5.4.

JAVA_HOME , ANT_HOME , ANDROID_HOME set correctly, PATH been expanded to include %JAVA_HOME%\bin , as well as %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools .

I can create a hello-world PhoneGap project as described here: http://phonegap.com/install/

A hello-world vanilla project that will build and run with configured AVD:

 phonegap run android --emulator 

However, when I try to import a project according to this tutorial in Android Studio 0.5.4 , it will not compile.

Firstly, import in 0.5.4 is completely different from what is shown on the linked page, there are none of the options presented (you can choose only the folder from which you want to import, the destination and whether to replace banks with dependencies, when possible "/" Replace library sources with dependencies, when possible "and" Create module names Gradle-style (camelCase) ", all selected by default).

Android Studio shows errors like:

 Error:(19, 26) error: package android.annotation does not exist Error:(26, 16) error: package org.json does not exist Error:(30, 23) error: package android.content does not exist 

However, I see < Android API 19 Platform > and < JDK > in the External Libraries section with android.jar and annotations.jar and, for example, android.annotation .

I tried to install minSdkVersion 19 for the helloWorld project, but that doesnโ€™t fix anything.

+6
source share
1 answer

I ran into the same problem, except with Cordova, and not with PhoneGap. I donโ€™t know what needs to be changed in an Android project so that it works in Android Studio (or Eclipse - it detects problems with both). A.

Instead, I started playing with versions. It seems that an error with Cordova version 3.5.0-0.2.4 does not happen with Cordoba version 3.0.0. Now it builds and works great for me.

Getting the old version of Cordoba is easy if on Mac OS X / * nix:

 sudo npm install -g cordova@3.0.0 

I suspect there is some error / inconsistency with later versions of Cordoba. Note. I chose v3.0.0 simply because I could not do this for v3.1 +.

If I get more time, I will try to analyze the differences between assembly 3.0.0 and assembly 3.5.0.

+1
source

All Articles