Alle Beiträge

1 Min. Lesezeit

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:

Bash
cordova create MyCordovaApp de.flatphormesmedia MyCordovaApp
Bash
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

Bash
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

Bash
MyCordovaApp\platforms\android\build.gradle 
MyCordovaApp\platforms\android\CordovaLib\build.gradle 

from

Groovy
dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
    }

to

Groovy
dependencies {
        classpath 'com.android.tools.build:gradle:1.0.+'
    }

and

Groovy
android {
    ...
        buildToolsVersion "19.0.0"
    ...

to

Groovy
android {
    ...
        buildToolsVersion "19.1.0"
    ...

Now it’s time to start your Android Studio and import the project with Gradle under

Groovy
MyCordovaApp\platforms\android\build.gradle .