Android Studio and PhoneGap, Module android is not backed by gradle

后端 未结 2 2039
梦如初夏
梦如初夏 2021-02-10 20:49

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

相关标签:
2条回答
  • 2021-02-10 21:23

    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:

    enter image description here

    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..

    0 讨论(0)
  • 2021-02-10 21:30

    From this link

    Cordova for Android now supports building with Gradle.

    To build cordova with gradle

    1. Right click on My computer -> properties -> Advanced system setting -> Environment Variables and create ANDROID_BUILD system variable with value gradle

    2. 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

    0 讨论(0)
提交回复
热议问题