Android支持库Gradle Conflict

问题描述 投票:3回答:3

我在我的应用程序中使用的Android支持库的不一致版本存在问题,但在我的Gradle中指定完全相同的版本后,我仍然得到相同的错误。

问题特别是在'com.android.support:appcompat-v7:23.1.0''com.android.support:support-v4:24.0.0'之间。即使在指定compile 'com.android.support:support-v4:23.1.0'之后,它仍然表示与support-v4:24.0.0存在冲突。任何有助于解决此问题的帮助将不胜感激。

enter image description here

编辑:下面是我的整个build.gradle文件。

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    compileSdkVersion 23
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId "com.company"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 48
        versionName "5.1.5"
        multiDexEnabled true
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'


    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:support-annotations:23.1.0'

    compile 'com.parse.bolts:bolts-android:1.4.0'
    compile files('libs/Parse-1.13.0/Parse-1.13.0.jar')

    compile 'com.pkmmte.view:circularimageview:1.1'

    compile 'com.google.code.gson:gson:2.7'

    // SugarORM
    compile 'com.github.satyan:sugar:1.5'

    compile 'com.android.support:multidex:1.0.1'

    // Firebase
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-messaging:10.2.0'

    // Google play services
    compile 'com.google.android.gms:play-services-location:10.2.0'
    compile 'com.google.android.gms:play-services-places:10.2.0'

    // Timber logging
    compile 'com.jakewharton.timber:timber:4.5.0'

    compile 'joda-time:joda-time:2.9.7'

    // Crashlytics
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
}

apply plugin: 'com.google.gms.google-services'
android android-gradle android-support-library
3个回答
2
投票

您需要在Linux中使用以下命令检查依赖关系树中的依赖关系:

./gradlew app:dependencies

或者,如果您使用的是Windows,请尝试以下操作:

gradlew.bat app:dependencies

然后,在找到与support-v4:24.0.0的依赖关系后,您可以使用以下命令将其排除:

compile('com.library.name:version') {
  //exclude group: 'com.android.support'
  //exclude module: 'support-v7'
  //exclude module: 'appcompat-v7'
  exclude module: 'support-v4'
}

0
投票

看看你的android DSL:

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
}

如果buildToolsVersion是25+,那么compileSdkVersion也应如此。

由于buildToolsVersion是25+,那么您的支持库也应该是这样的:

dependencies {
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-annotations:25.3.1'
}

0
投票

在这些情况下,当库版本与其他版本不同时,我建议您在依赖项中添加该库,其版本与其他版本相同。

在您的情况下,您可以使用版本25.3.1添加所有库。

© www.soinside.com 2019 - 2024. All rights reserved.