赞
踩
许多小伙伴将以前Android Studio老版本写的代码git下来后发现无法运行,这种情况大概率是Android Studio新老版本gradle目录结构不一样导致的。新版本中Android Studio将项目级build gradle的部分配置迁移到了setting gradle中。将他们改回原来的结构就好了。
例如原来的版本为7.2
现将它改为
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
原来的版本为
现在将红色框中的代码替换为
- buildscript {
-
- repositories {
- mavenCentral()
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.2.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
- }
-
- allprojects {
- repositories {
- google()
- jcenter()
- maven { url "https://jitpack.io" }
- }
- }

原来的格式为
现在将dependencyResolutionManagement注释
最后要注意gradle版本一定要和gradle插件版本保持一致
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。