Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. 解决办法

Compile a project that was packaged at home today and find that the company's computer compiles but the problem is as follows

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

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

 It was found that this problem was caused by a problem with the Gradle version

Enter the following command in Terminal according to the above prompt 

gradlew --warning-mode all

After compiling, there is the following prompt

> Configure project :
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's sunset in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further inform
ation: https://docs.gradle.org/7.2/userguide/upgrading_version_6.html#jcenter_deprecation
        at build_al187h50hbdustpaoood7j9ji$_run_closure1$_closure3$_closure5.doCall(G:\AndroidStudioProject\noaar\mjTest\mj\build.gradle:8)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

It is clear that the jcenter() function has been deprecated and replaced by the mavenCentral() function

Find the build.gradle file which was originally

allprojects {
    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:7.0.4'
        }
    }

    repositories {
        jcenter()
        google()
    }
...
}

Just modify it as follows

allprojects {
    buildscript {
        repositories {
            mavenCentral()
            google()
        }

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

    repositories {
        mavenCentral()
        google()
    }
...
}

Compiled again and found

Guess you like

Origin blog.csdn.net/qq_41973169/article/details/129079641