A while back I\'ve worked with Eclipse and Phonegap and I\'ve successfully deployed a few Android apps. So now I\'m trying to get the new Phonegap/Cordova app up and running in
Okay I've figured it out so I'll just answer my own question. Hopefully it will also benefit someone else trying to do the same thing.
There are actually two build.gradle files, one in the main project and one in the CordovaLib folder. I guess CordovaLib is a subproject within the main project. So after generating the Cordova project and importing it into Android Studio an error appears
Error:Gradle version 1.10 is required. Current version is 2.2.1.
Edit the build.gradle files and make the following change in both files:
change classpath 'com.android.tools.build:gradle:0.10.+'
to this : classpath 'com.android.tools.build:gradle:1.0.0'
Btw I know the error message said v1.10 but changing it to that gives another error "Could not find.." and "1.0.0" seems to work, so yeah go figure...
Then I select Build -> Rebuild Project from the menu and it gives another error
Error:The SDK Build Tools revision (19.0.0) is too low for project 'android'.
Minimum required is 19.1.0
Clicking on the error message unhelpfully does nothing, but I again edit the build.gradle files and change buildToolsVersion "19.0.0"
to buildToolsVersion "19.1.0"
in both files. To sum up the changes see screenshot below:
Then again select Build -> Rebuild Project
from the menu, and it will give an error in the Gradle Console
Error: Task '' not found in root project 'android'.
Just ignore it, and do Build -> Rebuild Project
again and then it will give an info dialog "Language level changes will take effect on project reload. Would you like to reload project "android" now?" and press Yes.
The project will reload and is now ready to run on a device or in the emulator. :) phew..
From this link
Cordova for Android now supports building with Gradle.
To build cordova
with gradle
Right click on My computer
-> properties
-> Advanced system setting
-> Environment Variables
and create ANDROID_BUILD system variable with value gradle
Now cordova build android
will create gradle project which can be easily imported as a android studio project.
Note :
If you are behind proxy then you have to set proxy first with
gradlew -Dhttp.proxyHost=proxy.blah.com -Dhttp.proxyPort=8000
gradlew batch file will be created automatically in your directory