Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0

AndroidUnit TestingGradleKotlinJunit5

Android Problem Overview


I've got a gradle FAILURE:

..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."

Case description:

  • Attached to the project codebase the next libs:

APP/build.gradle

    //(Required) Writing and executing Unit Tests on the JUnit Platform 
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
    // (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
    // (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"

testImplementation "io.mockk:mockk:1.8.5"
  • Updated the gradle-wrapper.properties

    distributionUrl=https....gradle-4.4-all.zip to 4.7-all

  • after all of that gradle was built success

  • created the test calss

      @TestInstance(TestInstance.Lifecycle.PER_CLASS)
        class TestClass {
    
        @Test
        internal fun testName() {
          Assert.assertEquals(2, 1 + 1)
        }
      }
    
  • ran the test and got the FAILURE message. enter image description here

  • ran the Gradle build with a command line argument ./gradlew --warning-mode=all to see what exactly the deprecated features are. enter image description here

As a result I couldn't build the app and I've got that FAILURE: message.

Android Solutions


Solution 1 - Android

Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.

It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.

Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.

Solution 2 - Android

Try this one

cd android && ./gradlew clean && ./gradlew :app:bundleRelease

Solution 3 - Android

The process below worked in my case- First check Gradle Version:

cd android
./gradlew -v

In my case it was 6.5

Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version. For gradle version 6.5, the plugin version is 4.1.0

Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>

Solution 4 - Android

I was getting this error. Turns out it only happened when I completely cleaned the RN caches (quite elaborate process) and then created a release build.

If I cleaned the caches, created a debug build and then a release build, everything worked. Bit worrying but works.

Note: My clean command is...

rm -r android/build ; rm -r android/app/src/release/res ; rm -r android/app/build/intermediates ; watchman watch-del-all ; rm -rf $TMPDIR/react-* ; npm start -- --reset-cache

Solution 5 - Android

My project was incompatible with Gradle 8.0 .Here's what worked for me: First I wrote this line of code in the Android Studio terminal:

./gradlew build --warning-mode all

When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.

Once I did these things, my project built perfectly and installed on my emulator

Solution 6 - Android

in my case i updated the build.gradle file and make the classpath to latest version from 3.5.2 to 3.6.3

dependencies {
        classpath("com.android.tools.build:gradle:3.6.3") 
    }

Solution 7 - Android

Important - Answer work only for REACT-NATIVE VS CODE Terminal

In VisualStudio code, you have to run like below then that warning will be omitted.

react-native run-android warning-mode=all

> If you run below then you will get the error in terminal When running react-native run-android --warning-mode all I get error: unknown option --warning-mode'

Solution 8 - Android

In my case adding multiDexEnabled true in Android/app/build.gradle file compiled the files.

I will look into removing this in the future, as in the documentation it says 'Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries.'

defaultConfig {
  applicationId "com.peoplesenergyapp"
  minSdkVersion rootProject.ext.minSdkVersion
  targetSdkVersion rootProject.ext.targetSdkVersion
  versionCode 1
  versionName "1.0"
  multiDexEnabled true // <-add this 
}

Solution 9 - Android

The following solution helped me as I was also getting the same warning. In your project level gradle file, try to change the gradle version in classpath

classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"

Solution 10 - Android

Update your third party dependencies. for example I updated dependency from implementation 'com.github.ybq:Android-SpinKit:1.1.0' to implementation 'com.github.ybq:Android-SpinKit:1.2.0'. and in my case issue has been solved.

Solution 11 - Android

It work for me in this issue in a project of react-native:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

244 actionable tasks: 2 executed, 242 up-to-date D8: Cannot fit requested classes in a single dex file (# fields: 67296 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html ....

I Did this:

Solution 12 - Android

Set distributionUrl path in gradle-wrapper-properties files as :

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

Solution 13 - Android

Finally decided to downgrade the junit 5 to junit 4 and rebuild the testing environment.

Solution 14 - Android

Solution for the issue: deprecated gradle features were used in this build making it incompatible with gradle 6.0. android studio This provided solution worked for me.

First change the classpath in dependencies of build.gradle of your project From: classpath 'com.android.tools.build:gradle:3.3.1' To: classpath 'com.android.tools.build:gradle:3.6.1'

Then make changes in the gradle-wrapper.properties file this file exists in the Project's gradle>wrapper folder From: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip To: distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Then Sync your gradle.

Solution 15 - Android

Uninstall the old app from the device/emulator. It worked for me

Solution 16 - Android

i'am using react-native and this works for me :

  1. in root of project cd android and gradlew clean

  2. open task manager in windows

  3. on tab 'Details' hit endtask on both java.exe proccess

long story short > Task :app:installDebug FAILED Fixed by kiling java.exe prossess

Solution 17 - Android

On a SpringBoot project using IntelliJ and Gradle, I got the warning "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0" when running my integration test. What solved the problem was:

  • Going to: File > Settings > Build, Execution, Deployment
  • Selecting for "Build and run using": Intellij IDEA (instead of "Gradle")
  • Same for "Run tests using" That did not explain why Gradle is displaying the warning, but that let me perform the test and progress in my work.

Solution 18 - Android

I found my disk space is less than 4 GB and can not get the Gradle lib repo then show

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

just remove tmp and junk files, free up space then try build and resolve problem

Solution 19 - Android

In my case deleting the whole android folder from the base directory and allowing it to rebuild all of it on eas build fixed this error for me :)

Solution 20 - Android

it is due to incompatibility.

please upgrade classpath("com.android.tools.build:gradle:4.0.1") in build.gradle file under android folder.

Solution 21 - Android

Check settings.gradle script and remove jcenter() from that it may be causing the issue as it is deprecated.

You're new settings.gradle file should be

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    plugins {
        id 'com.android.application' version '7.1.0-alpha12'
        id 'com.android.library' version '7.1.0-alpha12'
        id 'org.jetbrains.kotlin.android' version '1.5.21'
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "ComposePlayground"
include ':app'

> Take note that ComposePlayground is app name.

Solution 22 - Android

I Sloved this problem by updating my gradle-wrapper.properties file. You have to change this line distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip to the lates gradle build which can be found at The Gradle Wrapper.

Hope that helps someone out there :)

Solution 23 - Android

Try this solution worked for me.
If you have another app with the same name (or package name) on the device: Rename the app or delete it from your device.

Solution 24 - Android

Solved this issue by deleting the .gradle folder from /android and again run npm run android, and it solved this error. Here's a link to the issue: https://github.com/facebook/react-native/issues/28954

Solution 25 - Android

1)cd android 2) ./gradlew clean 3)./gradlew :app:bundleRelease

then last install npm install command

Solution 26 - Android

Add implementation("org.slf4j:slf4j-nop:1.7.25") to build.gradle.kts.

Solution 27 - Android

It was fixed this kind of error after migrate to AndroidX

  • Go to Refactor ---> Migrate to AndroidX

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPhilipp BuhaievskiyView Question on Stackoverflow
Solution 1 - AndroidhotkeyView Answer on Stackoverflow
Solution 2 - AndroidMasum BillahView Answer on Stackoverflow
Solution 3 - AndroidShafin HasnatView Answer on Stackoverflow
Solution 4 - AndroidchichilatteView Answer on Stackoverflow
Solution 5 - AndroidKevin GermainView Answer on Stackoverflow
Solution 6 - AndroidMoumitView Answer on Stackoverflow
Solution 7 - AndroidAvid ProgrammerView Answer on Stackoverflow
Solution 8 - AndroidverunarView Answer on Stackoverflow
Solution 9 - Androidpriyanka.bView Answer on Stackoverflow
Solution 10 - AndroidHirenView Answer on Stackoverflow
Solution 11 - AndroidNerioLoronaView Answer on Stackoverflow
Solution 12 - AndroidGautam DevView Answer on Stackoverflow
Solution 13 - AndroidPhilipp BuhaievskiyView Answer on Stackoverflow
Solution 14 - AndroidNawab Singh KoliView Answer on Stackoverflow
Solution 15 - AndroidcetricView Answer on Stackoverflow
Solution 16 - Androidfaryar76View Answer on Stackoverflow
Solution 17 - AndroidOmar DView Answer on Stackoverflow
Solution 18 - AndroiddinobiView Answer on Stackoverflow
Solution 19 - AndroidShep SimsView Answer on Stackoverflow
Solution 20 - AndroidManan GadhiyaView Answer on Stackoverflow
Solution 21 - AndroidVidyesh ChuriView Answer on Stackoverflow
Solution 22 - AndroidlunguView Answer on Stackoverflow
Solution 23 - AndroidMoustaoui SalaheddineView Answer on Stackoverflow
Solution 24 - AndroidsabrimView Answer on Stackoverflow
Solution 25 - AndroidAhsan Raza AlviView Answer on Stackoverflow
Solution 26 - AndroidPaulo Roberto MarquesView Answer on Stackoverflow
Solution 27 - Androiddamith alahakoonView Answer on Stackoverflow