Shai UI
Shai UI

Reputation: 51958

How to Get Cordova to Work With Android Studio?

I have the newest everything, node, npm, android studio, cordova.

I created a new project with:

cordova create test
cd test
cordova platform add android

I go into Android Studio, import project, go to test/platforms/android it finds the build.gradle file, works on it for awhile then spits out:

Gradle version 1.10 is required. Current version is 2.2.1

So I go to my build.gradle file, and update the line

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

to:

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

And then I re-import my project, it chugs on it for awhile, then spits out:

Error:failed to find Build Tools revision 19.0.0

So I install Build Tools 19.0.0

And it tells me:

Error:The SDK Build Tools revision (19.0.0) is too low for project 'android'. Minimum required is 19.1.0

So I look at my SDK Manager and I have 19.1.0 installed

So I go back into my build.gradle file:

and I change:

buildToolsVersion "19.0.0"

to

buildToolsVersion "19.1.0"

And re-import again,

And still tells me: Error:The SDK Build Tools revision (19.0.0) is too low for project ':CordovaLib'. Minimum required is 19.1.0

I even try and delete SDK Build Tools revision 19, and keep 19.1 but it still tells me that.

Can anyone that has done this song and dance please help me?

Upvotes: 8

Views: 15174

Answers (4)

Mael
Mael

Reputation: 31

I solved the problem, modifing gradle file App and gradle file CordovaLib, with the following information:

changed   dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0+'
    }
}

and

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"
}

Tested on Android Studio 1.1

Upvotes: 3

Michael Szabo
Michael Szabo

Reputation: 235

I had exactly the same problem and just fixed it. What you need to do is complete the same buildToolsVersion "19.1.0" change to the build.gradle file in the CordovaLib folder within your platform project folder e.g. platforms/android/CordovaLib.

Upvotes: 7

jacko
jacko

Reputation: 131

I had same problem. In the end choosing "Import Non-Android Studio project" and navigating to the android folder platforms/android worked. Wasn't sure if you initially choose the "Import Non-Android Studio project" option.

Upvotes: 1

Jean-Denis Gingras
Jean-Denis Gingras

Reputation: 1

I had the same problem and corrected the content of build.gradle directly in Android Studio (replacing 19.0.0 with 19.1.0). The build was succeful after that. Of course, this is only a workaround until the Cordova team fixes the problem permanently. Good luck.

Upvotes: 0

Related Questions