当前位置: 首页 > 知识库问答 >
问题:

Android依赖项具有不同的编译和运行时版本

司徒耀
2023-03-14

将Android Studio从Canary 3更新到Canary 4后,在构建时抛出以下错误。

Android依赖项“com.Android.support:support-support-v4”的编译类路径(25.2.0)和运行时类路径(26.0.0-beta2)版本不同。您应该通过DependencyResolution手动设置相同的版本。

app-build.gradle

android {
compileSdkVersion 26
buildToolsVersion '26.0.0'


defaultConfig {
    applicationId "com.xxx.xxxx"
    minSdkVersion 14
    targetSdkVersion
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}


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

    lintOptions {
        abortOnError false
    }

}}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation project(':core')
implementation com.google.android.gms:play-services-gcm:9.0.0'

implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
    transitive = true
}
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.flurry.android:analytics:7.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
implementation 'com.jakewharton:butterknife:8.6.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

Library-Build.Gradle:

apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
    minSdkVersion 14
    targetSdkVersion
    versionCode 1
    versionName "1.0"
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/model.jar')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:percent:26.0.0-beta2'
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
implementation 'com.android.support:support-core-utils:26.0.0-beta2'

implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.picasso:picasso:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.2.0'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.android.support:design:26.0.0-beta2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'

}

注:项目为金丝雀3号大楼

共有1个答案

秦阳旭
2023-03-14

在构建脚本(build.gradle根)中使用以下代码:

subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "version which should be used - in your case 26.0.0-beta2"
        }
     }
  }
}
 类似资料:
  • 我甚至不知道从哪里开始找到解决这个问题的方法。请帮帮忙。

  • 问题内容: 昨天我的应用程序正确构建,今天没有更改我无法构建的任何内容,我收到此错误: Android依赖项“ com.google.android.gms:play-services- stats”具有不同的编译版本(16.0.1)和运行时版本(17.0.0)> classpath。您应该通过> DependencyResolution手动设置相同的版本 我尝试使用“ com.google.gm

  • 当将项目与gradle文件同步时,Android Studio显示此错误: 我试着用: 以下是我定义其余rx库的方式: 我有什么想法可以解决这个问题吗?

  • 我需要使用WebSocket,但是我们使用的旧版本的PHP不支持它们。我决定尝试一个Java的WebSocket服务器。我已经在Android Studio中编写了一些Android应用程序,所以我熟悉Java的基本语法,但是几乎没有手动编译和运行java的经验。 我希望服务器是一个单一的文件,我可以从命令行运行一次,然后忘记它。为此,我决定使用这个库,在示例中包含一个Javascript聊天应用

  • Java和Maven新手。 我试图配置我的应用程序,以便我可以通过cmd线生成一个jar,其中包含我所有的依赖项。 据我所知,我正在正确设置Pom以使用此插件:https://github.com/javafx-maven-plugin/javafx-maven-plugin 以下是我在Pom中的依赖项: 在我的

  • 问题内容: 我有一个Maven项目,我通常可以从eclipse编译并运行它,但是当我从命令行编译它时,它的依赖项丢失了,并且出现了错误。只有下载依赖项并将它们添加到c:/ Java / jdk / jre / lib / ext后,我才能编译项目 如何从控制台行编译项目及其依赖项,而无需将其手动添加到jdk?编译器可以以某种方式读取Maven依赖项吗? pom.xml 问题答案: 从具有某些mav