Phonegap / Cordova 4.x app with Android Studio 1.x
I assume that you have a working installation of PhoneGap or Cordova CLI. In this post I use the Cordova CLI which is distributed as an npm package in a ready-to-use format (npm install -g cordova
).
At first we have to create the app and at the android platform with the Cordova CLI:
cordova create MyCordovaApp de.flatphormesmedia MyCordovaApp
MyCordovaApp\cordova platform add android
Next we have to build the the project for the Android platform. This step is important as it adds the android target to the Cordova project
MyCordovaApp> cordova build android
Cordova 4.1.2 and prior still generates Gradle 1.x files so you have to change the following lines in both build.gradle files under
MyCordovaApp\platforms\android\build.gradle
MyCordovaApp\platforms\android\CordovaLib\build.gradle
from
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
}
and
android {
...
buildToolsVersion "19.0.0"
...
to
android {
...
buildToolsVersion "19.1.0"
...
Now it’s time to start your Android Studio and import the project with Gradle under
MyCordovaApp\platforms\android\build.gradle .