简体   繁体   English

依赖关系是最新的,但Gradle认为不是

[英]Dependencies are up-to-date but Gradle thinks not

Why does Gradle give this error about dependencies when I have used the latest and same version? 当我使用最新版本和相同版本时,为什么Gradle会提供有关依赖项的错误? This has only just started today and I'm lost as to how to fix this: 这只是刚刚开始今天,我迷失了如何解决这个问题:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). 所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。 Found versions 28.0.0, 26.1.0. 找到的版本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 示例包括com.android.support:animated-vector-drawable:28.0.0和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'
}

ʍѳђઽ૯ท's suggestion ʍѳђʍѳђ9sugges的建议

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

Maybe this is because support library version 28 hasn't any library that call it 也许这是因为支持库版本28没有任何调用它的库

implementation 'com.android.support:animated-vector-drawable-v7:28.0.0'

or 要么

implementation 'com.android.support:support-media-compat-v7:28.0.0'

Or Maybe this is because you are using support library version 28, but targetSdkVersion is lower than version 28. 或者这可能是因为您使用的是支持库版本28,但targetSdkVersion低于版本28。

(in Android Studio v:3.1.4)If you would like to add another library to your project, use the following URL (在Android Studio v:3.1.4中)如果要将另一个库添加到项目中,请使用以下URL

(from toolbar) file \ Project Structure ... \ (from left window : under modules) app \ Dependencies \ (use green plus)

This work for me : Add this lines in build.gradle (Project Gradle) 这项工作对我来说:在build.gradle中添加这一行(Project 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'
}

Doing ./gradlew app:dependencies on the terminal will show the different dependenices with their versions. 在终端上执行./gradlew app:dependencies将显示与其版本不同的依赖项。 To fix this easily, just add the dependency which has old and not has the same version (as the other related) dependencies in your Build.gradle . 要轻松解决这个问题,只需添加旧的依赖项,而不要在Build.gradle添加相同版本(与其他相关的)相关性。

If you hold on the error , it will show which dependency is old and then you can see the differences between the versions. 如果你坚持错误 ,它将显示哪个依赖项是旧的,然后你可以看到版本之间的差异。

As an example, if you add this as the newest version like the other related dependencies, it will be fixed: 例如,如果您将其添加为最新版本,就像其他相关依赖项一样,它将被修复:

implementation 'com.android.support:support-media-compat:28.0.0' // just like the other related dependencies versions.

In your case, one of them is using 26.1.0 version: 在您的情况下,其中一个使用26.1.0版本:

Found versions 28.0.0, 26.1.0 找到的版本28.0.0,26.1.0

one could also exclude version 26.1.0 from a dependency, but here's how to enforce 28.0.0 : 也可以从依赖项中排除版本26.1.0 ,但这里是如何强制执行28.0.0

configurations.all() {
    resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
}

this might be coming from: 这可能来自:

implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"

run ./gradlew app:dependencies from the project's root directory to see where it comes from. 运行./gradlew app:dependencies来自项目根目录的./gradlew app:dependencies ,以查看它的来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取最新的GPS位置 - Get up-to-date GPS Location 检测到我的应用程序小部件的数据不是最新的 - Detecting that my app widget's data is not up-to-date 如何始终保持对活动的最新引用 - How to keep always up-to-date reference to Activity 从服务中读取时首选项不是最新的 - Preferences not up-to-date when read from service Android Studio停留在对话框中,提示类最新检查 - Android studio stuck at dialog saying Classes up-to-date check Android Studio 在我的应用程序上发出警告:app:stripDebugDebugSymbols UP-TO-DATE - Android Studio Warning on my app: app:stripDebugDebugSymbols UP-TO-DATE 使用Closure整理Gradle依赖项 - Tidying up Gradle dependencies using Closure 在 android 工作室中设置 gradle 和 gradle 插件和依赖项 - Setting up gradle and gradle plugin and dependencies in in android studio Android Studio 2.1.1,完全最新,IDE刚刚崩溃,我的项目文件消失了 - Android Studio 2.1.1, fully up-to-date, IDE just crashed, and my project files disappeared 离子无法在最新检查期间捕获任务“:app:preDebugBuild”属性“compileManifests”的输入文件的指纹 - Ionic Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM