gpt4 book ai didi

android - 迁移到AndroidX时无法解决gradle版本错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:07:27 26 4
gpt4 key购买 nike

当我尝试将自己的项目迁移到 AndroidX 时,错误消息出现在错误对话框中:

The gradle plugin version in your project build.gradle file needs to be set to at least com.android.tools.build:gradle:3.2.0 in order to migrate to AndroidX.

然后在网上google了一下这个错误。发现一个站点说 classpath 'com.android.tools.build:gradle:3.2.0' 必须添加到 build.gradle。因此,我像这样将行添加到 build.gradle 中:

apply plugin: 'com.android.library'

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-core-utils:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

buildscript {
repositories {
google()
jcenter()
}

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

allprojects {
repositories {
google()
jcenter()
}
}

但是,同样的错误发生了。我错过了什么吗?

最佳答案

检查项目级别(不是模块)的build.grade

并更改android gradle plugin的版本:

buildscript {
...

dependencies {
...
classpath 'com.android.tools.build:gradle:3.4.1' // it should be more than 3.2.0
}
}

关于android - 迁移到AndroidX时无法解决gradle版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56764413/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com