21

Yesterday I upgraded Android Studio to version 3.0, but I'm working with LibGdx and after the upgrade I cannot build my project.

When I'm try to build, it gives me an error:

Error:(2, 0) Plugin with id 'jetty' not found

How should I fix this?

DBS
  • 9,110
  • 4
  • 35
  • 53
B. Eugenio
  • 313
  • 1
  • 2
  • 5

2 Answers2

50

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

Android Studio 3.0 using Gradle-4.1 and android-gradle-plugin: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


If you still want to use Android Studio 3.0

  • Downgrade Gradle to 3.3 from 4.1

    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 to 2.3.3 from 3.0.0

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

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

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

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. Find root build.gradle file of your project and add Google's Maven repo in project repositories list as well as in buildScript repo list

    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.

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65
  • Great, this helped! Is there a way to find out what update is safe to apply before it crashes your project? – MilanG Nov 07 '17 at 07:02
  • crashes ?? If you're talking about desktop crash, you can use Terminal to run your desktop project. – Abhishek Aryan Nov 08 '17 at 19:02
  • After the update I was not able to build the project at all. That's the crash I'm talking about. I would like to know what update is safe before I run it. – MilanG Nov 13 '17 at 13:32
  • I downgraded Gradle as you explained and it works well again. Error was the same as Eugenio explained at his question at top. – MilanG Nov 14 '17 at 10:11
  • Can you run the Desktop module also with this fix? – Julien Nov 18 '17 at 18:39
  • @Julien yes, you can run desktop module – Abhishek Aryan Nov 18 '17 at 19:08
  • 1
    Worked for me! Thank you! – Taylor Liss Nov 29 '17 at 19:38
  • 2
    Thanks worked for me too, just found the "gradle-wrapper.properties" inside folder "gradle/wrapper" and found both "com.android.tools.build:gradle:3.0.1" and "google()" in the "build.gradle" file. Hope this helps, because everyone is expected to come to this answer whose not familiar with gradle options. Good Day – Diljeet Dec 16 '17 at 17:46
  • 1
    Worked for me too. If you get an error like "Error:(74, 0) Gradle DSL method not found: 'implementation()'" make sure to replace all the 'implementation' calls back to 'compile' in build.gradle projects dependencies. – Pimentoso Mar 21 '18 at 10:41
0

Suggestion from Jetty Plugin team is to switch to gretty

Please check this Error while replacing jetty plugin to gretty plugin gradle

Rafael
  • 2,521
  • 2
  • 33
  • 59