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()
    }
}

能运行了

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值