依赖项是最新的,但 Gradle 认为不是
Dependencies are up-to-date but Gradle thinks not
为什么 Gradle 当我使用了最新且相同的版本时会出现有关依赖项的错误?这只是今天才开始,我不知道如何解决这个问题:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable-v7:28.0.0'
implementation 'com.android.support:support-media-compat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
ʍьђઽ૯ท的建议
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not generate a proxy class for class com.android.build.gradle.tasks.BuildArtifactReportTask.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
在终端上执行 ./gradlew app:dependencies
将显示不同版本的依赖项。要轻松解决此问题,只需在 Build.gradle
.
中添加具有旧版本且不具有相同版本 (与其他相关) 依赖项的依赖项
如果您坚持错误,它将显示哪个依赖项是旧的,然后您可以看到版本之间的差异。
例如,如果您像其他相关依赖项一样将其添加为最新版本,它将得到修复:
implementation 'com.android.support:support-media-compat:28.0.0' // just like the other related dependencies versions.
在你的例子中,其中一个正在使用 26.1.0
版本:
Found versions 28.0.0, 26.1.0
也可以从依赖项中排除版本 26.1.0
,但这里是强制执行 28.0.0
的方法:
configurations.all() {
resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
}
这可能来自:
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
运行./gradlew app:dependencies
从项目的根目录中查看它来自哪里。
可能是因为支持库版本 28 没有任何调用它的库
implementation 'com.android.support:animated-vector-drawable-v7:28.0.0'
或
implementation 'com.android.support:support-media-compat-v7:28.0.0'
或者可能是因为你使用的是28版本的支持库,但是targetSdkVersion低于28版本。
(in Android Studio v:3.1.4)如果您想将另一个库添加到您的项目中,请使用以下 URL
(from toolbar) file \ Project Structure ... \ (from left window : under modules) app \ Dependencies \ (use green plus)
这对我有用:在 build.gradle(项目 Gradle)中添加此行
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "your project"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
为什么 Gradle 当我使用了最新且相同的版本时会出现有关依赖项的错误?这只是今天才开始,我不知道如何解决这个问题:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable-v7:28.0.0'
implementation 'com.android.support:support-media-compat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
ʍьђઽ૯ท的建议
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not generate a proxy class for class com.android.build.gradle.tasks.BuildArtifactReportTask.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
在终端上执行 ./gradlew app:dependencies
将显示不同版本的依赖项。要轻松解决此问题,只需在 Build.gradle
.
如果您坚持错误,它将显示哪个依赖项是旧的,然后您可以看到版本之间的差异。
例如,如果您像其他相关依赖项一样将其添加为最新版本,它将得到修复:
implementation 'com.android.support:support-media-compat:28.0.0' // just like the other related dependencies versions.
在你的例子中,其中一个正在使用 26.1.0
版本:
Found versions 28.0.0, 26.1.0
也可以从依赖项中排除版本 26.1.0
,但这里是强制执行 28.0.0
的方法:
configurations.all() {
resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
}
这可能来自:
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
运行./gradlew app:dependencies
从项目的根目录中查看它来自哪里。
可能是因为支持库版本 28 没有任何调用它的库
implementation 'com.android.support:animated-vector-drawable-v7:28.0.0'
或
implementation 'com.android.support:support-media-compat-v7:28.0.0'
或者可能是因为你使用的是28版本的支持库,但是targetSdkVersion低于28版本。
(in Android Studio v:3.1.4)如果您想将另一个库添加到您的项目中,请使用以下 URL
(from toolbar) file \ Project Structure ... \ (from left window : under modules) app \ Dependencies \ (use green plus)
这对我有用:在 build.gradle(项目 Gradle)中添加此行
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "your project"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:design:28.0.0'
}