LibGdx doesn't working after updating Gradle (Android Studio 3.0)

后端 未结 4 832
深忆病人
深忆病人 2020-12-19 12:29

I have recently updated android studio and gradle to the version 3.0.0 following instructions in this link https://developer.android.com/studio/build/gradle-plugin-3-0-0-mig

相关标签:
4条回答
  • 2020-12-19 12:46

    Edit configurations -> Desktop -> In before launch change "Build" to "Build project". (use the + and - buttons).

    0 讨论(0)
  • 2020-12-19 12:56

    worked with windows , in terminal you can go to the project folder and run desktop module using command .

    gradlew desktop:run
    
    0 讨论(0)
  • 2020-12-19 12:58

    Android Studio 3.0 using gradle-4.1 and com.android.tools.build:gradle:3.0.0

    Gradle 4.1 is not supported yet in LibGDX, there is an issue for the same, which is now upgraded for Gradle 4.6

    Currently html module using deprecated jetty plugin which is removed in Gradle 4.1 version.

    However using Terminal you can run desktop module, I've not tested on windows but on Mac it's working fine.

    ./gradlew desktop:run
    

    For now you can use lower version of Gradle and Andoid-gradle-plugin in Android Studio 3.0 and wait for issue to be fixed.

    • Downgrade Gradle version from 4.1 to 3.3

      Find gradle folder inside your project, Open gradle-wrapper.properties and change distributionUrl for 3.3

      distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
      
    • Downgrade Android-gradle-plugin version from 3.0.0 to 2.3.3

      Open root build.gradle file and find artifact in buildscript and change version

      classpath 'com.android.tools.build:gradle:2.3.3'
      
    • Comment/delete google() from repo list inside root build.gradle file

    --------------------------------------------------------------------------------

    EDIT : Update LibGDX project to Gradle 4.6 - AS USER

    1. Upgrade Gradle to 4.6 :

      distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
      
    2. Add Google's Maven repo in project repositories list as well as in buildScript repo list in root build.gradle file.

      repositories {
          //.. 
          google()
          jcenter()         // Required for org.jetbrains.trove4j:trove4j library
      }
      
    3. Update Android Gradle Plugin :

      classpath 'com.android.tools.build:gradle:3.1.3'

      Known issues with the Android Gradle Plugin

      Configuration on demand with Gradle 4.6 and above:

      If you're using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above, you should disable configuration on demand to avoid some unpredictable build errors. (If you are using Android Gradle Plugin 3.2.0 or higher, you do not need to take any action to disable configuration on demand.)

      Disable configuration on demand in your gradle.properties file as shown below:

      • org.gradle.configureondemand=false

      • To disable configuration on demand in the Android Studio settings, choose File > Settings (Android Studio > Preferences on Mac), select the Compiler category in the left pane, and clear the Configure on demand checkbox.

        In Android Studio 3.2 Beta 1 and higher, the options for enabling configuration on demand have been removed.

    4. Update Android buildToolsVersion to 27.0.3 and SdkVersion to 27

    5. Remove instrumentTest.setRoot('tests') from sourceSets inside android build.gradle file
    6. replace all compile with implementation inside root build.gradle file
    7. New GWT Gradle Plugin added in html module, check latest build.gradle of html module.

    Run your project with Run Configuration or On Terminal using gradle task.


    If you're going to create new project use gdx-setup.jar of latest build.

    0 讨论(0)
  • 2020-12-19 13:09

    I temporarily solve this by forcing plugin to use 2.3.3 and gradle wrapper properties file reverted to 3.3

    distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
    

    and build.gradle

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

    comment out the google() from repositories and tell android studio 3.0 to stop reminding you to upgrade gradle plugin to 3.0.0 for your current project.

    Edit: To the person above who plagiarised my answer, shame on you!

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