gradle从7.0.2降级到6.5 报错

gradle-wrapper.properties修改​

前:​​​​​​distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
后:distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

报错 :

A problem occurred evaluating settings 'zDelete'.
> Could not find method dependencyResolutionManagement() for argument.....

原因:gradle 从6.8开始引入了,依赖解析管理。

删除settings.gradle 中 依赖解析管理相关的设置

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

报错:Minimum supported Gradle version is 7.0.2. Current version is 6.5.

原因:忘了改buil.gradle(project) 中的 classpath "com.android.tools.build:gradle:7.0.0"

改为  classpath "com.android.tools.build:gradle:4.1.3"

运行报错,发现各种依赖找不到。

: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.core:core-ktx:1.6.0 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.appcompat:appcompat:1.3.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency com.google.android.material:material:1.4.0 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.constraintlayout:constraintlayout:2.1.0 because no repositories are defined.
     Required by:
         project :app
原因:没有设置依赖仓库添加

在buil.gradle(project)

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

能运行了

你可能感兴趣的:(android,android)