将现有项目传递给 androidx 给了我无法解决 com.google.android:support-v4:r11



我正在将代码更改为 androidx,但在我尝试 gradle sync 时出现以下错误:

ERROR: Unable to resolve dependency for ':Debug/compileClasspath': Could not resolve com.google.android:support-v4:r11.
Show Details
Affected Modules: AppName

ERROR: Unable to resolve dependency for ':DebugAndroidTest/compileClasspath': Could not resolve com.google.android:support-v4:r11.
Show Details
Affected Modules: AppName

ERROR: Unable to resolve dependency for ':DebugUnitTest/compileClasspath': Could not resolve com.google.android:support-v4:r11.
Show Details
Affected Modules: AppName

我尝试过的事情: 1:进入文件->其他设置->默认设置->构建,执行,部署->构建工具->Gradle->取消选中离线工作选项。 未选中脱机选项。

  1. 使缓存失效并重新启动。这什么也没发生,出现同样的错误。

  2. 清理项目/
  3. 重建项目/使用gradle文件同步项目/重新启动Android工作室。出现相同的错误。

格拉德尔文件

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
minSdkVersion 20
targetSdkVersion 28
applicationId "com.myapp"
multiDexEnabled true
}
flavorDimensions "default"
productFlavors {
myapp {
minSdkVersion 20
applicationId 'be.myapp
targetSdkVersion 28
versionCode 130
versionName '2.5.3'
signingConfig signingConfigs.myapp
manifestPlaceholders = [ROTATION_PREF: "unspecified"]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}
configurations {
all*.exclude group: 'com.android.volley'
}
}
repositories {
maven {
url 'https://maven.google.com'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('de.keyboardsurfer.android.widget:crouton:1.8.1') {
implementation 'com.google.maps.android:android-maps-utils:0.3+'
}
annotationProcessor 'org.parceler:parceler:1.1.1'
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup:otto:1.3.5'
implementation 'com.squareup.picasso:picasso:2.3.2'
annotationProcessor 'io.realm:realm-android:0.82.0-SNAPSHOT'
implementation 'io.realm:realm-android:0.82.0-SNAPSHOT'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.parceler:parceler-api:1.1.1'
implementation 'org.apache.amber:amber-oauth2-client:0.22-incubating'
implementation 'org.apache.amber:amber-oauth2-common:0.22-incubating'
implementation 'org.slf4j:slf4j-api:1.7.12'
implementation 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
}

解决方案:这是一个库不兼容的问题。 将org.parceler:parceler实现更改为新版本并检查所有库是否具有最新版本,错误已消失

尝试删除此行,添加

implementation 'androidx.appcompat:appcompat:1.1.0-rc01' 

并检查其他工件设置正确:https://developer.android.com/jetpack/androidx/migrate

相关内容

最新更新