"Failed to resolve: support-v4" 升级后 android studio
"Failed to resolve: support-v4" after upgrading android studio
当我决定将 android studio 从 3.0.1 升级到 3.1.2 时,我正在做一个项目,从那以后,我在构建我的应用程序时遇到了这个错误。 我知道之前有人问过类似的问题,但不同的是,它不提供有问题的库的版本。所以这显然是一个不同的问题。
这是截图
应用级别 build.gradle:
android {
compileSdkVersion 27
defaultConfig {
applicationId "..."
minSdkVersion 18
targetSdkVersion 27
versionCode 16
versionName "1.1.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
}
ext {
lifecycleLibVersion = '1.1.1'
supportLibVersion = '27.1.1'
daggerLibVersion = '2.15'
gmsLibVersion = '11.8.0'
persistenceLibVersion = '1.0.0'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "android.arch.lifecycle:extensions:$lifecycleLibVersion"
implementation "android.arch.persistence.room:runtime:$persistenceLibVersion"
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:cardview-v7:$supportLibVersion"
implementation "com.android.support:design:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "com.android.support:support-vector-drawable:$supportLibVersion"
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.android.gms:play-services-location:$gmsLibVersion"
implementation "com.google.android.gms:play-services-maps:$gmsLibVersion"
implementation "com.google.dagger:dagger-android-support:$daggerLibVersion"
implementation "com.google.firebase:firebase-core:$gmsLibVersion"
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.github.lawloretienne:discreteslider:0.0.9'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation "com.commonsware.cwac:saferoom:0.3.4"
annotationProcessor "android.arch.persistence.room:compiler:$persistenceLibVersion"
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
annotationProcessor "com.google.dagger:dagger-compiler:$daggerLibVersion"
annotationProcessor "com.google.dagger:dagger-android-processor:$daggerLibVersion"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
和项目级别build.gradle:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}
}
经过几天与这个问题的斗争,我终于找到了办法。
解决方法是删除~/.gradle
里面的caches
文件夹,重新下载依赖
Gradle构建日志解释了问题:
> Could not find support-v4.aar (com.android.support:support-v4:26.1.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.aar
即使我没有在任何地方明确支持 v4,这个库 implementation 'com.android.support:percent:26.1.0'
才是真正的原因。
升级到 compileSdkVersion 27
解决了问题。
allprojects {
repositories {
mavenLocal()
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
我终于通过在 jcenter()
上面使用 maven { url 'https://maven.google.com' }
解决了它。
https://github.com/rebeccahughes/react-native-device-info/issues/414
当我决定将 android studio 从 3.0.1 升级到 3.1.2 时,我正在做一个项目,从那以后,我在构建我的应用程序时遇到了这个错误。 我知道之前有人问过类似的问题,但不同的是,它不提供有问题的库的版本。所以这显然是一个不同的问题。 这是截图
应用级别 build.gradle:
android {
compileSdkVersion 27
defaultConfig {
applicationId "..."
minSdkVersion 18
targetSdkVersion 27
versionCode 16
versionName "1.1.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
}
ext {
lifecycleLibVersion = '1.1.1'
supportLibVersion = '27.1.1'
daggerLibVersion = '2.15'
gmsLibVersion = '11.8.0'
persistenceLibVersion = '1.0.0'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "android.arch.lifecycle:extensions:$lifecycleLibVersion"
implementation "android.arch.persistence.room:runtime:$persistenceLibVersion"
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:cardview-v7:$supportLibVersion"
implementation "com.android.support:design:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "com.android.support:support-vector-drawable:$supportLibVersion"
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.android.gms:play-services-location:$gmsLibVersion"
implementation "com.google.android.gms:play-services-maps:$gmsLibVersion"
implementation "com.google.dagger:dagger-android-support:$daggerLibVersion"
implementation "com.google.firebase:firebase-core:$gmsLibVersion"
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.github.lawloretienne:discreteslider:0.0.9'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation "com.commonsware.cwac:saferoom:0.3.4"
annotationProcessor "android.arch.persistence.room:compiler:$persistenceLibVersion"
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
annotationProcessor "com.google.dagger:dagger-compiler:$daggerLibVersion"
annotationProcessor "com.google.dagger:dagger-android-processor:$daggerLibVersion"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
和项目级别build.gradle:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}
}
经过几天与这个问题的斗争,我终于找到了办法。
解决方法是删除~/.gradle
里面的caches
文件夹,重新下载依赖
Gradle构建日志解释了问题:
> Could not find support-v4.aar (com.android.support:support-v4:26.1.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.aar
即使我没有在任何地方明确支持 v4,这个库 implementation 'com.android.support:percent:26.1.0'
才是真正的原因。
升级到 compileSdkVersion 27
解决了问题。
allprojects {
repositories {
mavenLocal()
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
我终于通过在 jcenter()
上面使用 maven { url 'https://maven.google.com' }
解决了它。
https://github.com/rebeccahughes/react-native-device-info/issues/414