繁体   English   中英

库和项目android之间的Gradle依赖冲突

[英]Gradle dependency conflict between library and project android

我正在构建一个Android项目。 使用以下gradle配置。 一切都很好。 直到我尝试在项目中添加lottie-android库。

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.ignite.a01hw909350.kolamdemo"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    aaptOptions {
        noCompress 'KARMarker'
        noCompress 'armodel'
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':KudanAR')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'nl.dionsegijn:konfetti:1.0.2'
    compile 'me.zhanghai.android.materialprogressbar:library:1.4.1'
    compile 'io.palaima:smoothbluetooth:0.1.0'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.afollestad.material-dialogs:core:0.9.3.0'
    compile 'com.flurgle:camerakit:0.9.17'
    compile 'com.github.zhukic:sectioned-recyclerview:1.0.0'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.prolificinteractive:material-calendarview:1.4.3'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'com.android.support:design:25.3.1'
    compile 'com.github.barteksc:android-pdf-viewer:2.4.0'
    compile 'org.rajawali3d:rajawali:1.1.668@aar'
    compile 'com.tapadoo.android:alerter:2.0.0'
    compile 'com.google.android.gms:play-services-location:11.0.4'
    compile 'com.github.GoodieBag:ProtractorView:v1.2'
    compile 'com.android.support:gridlayout-v7:25.3.1'
    compile 'com.stepstone.stepper:material-stepper:3.3.0'
    compile 'pub.devrel:easypermissions:0.4.3'
    compile 'com.intuit.sdp:sdp-android:1.0.4'
    compile 'com.github.apl-devs:appintro:v4.2.2'
    compile 'com.airbnb.android:lottie:2.2.5'
    testCompile 'junit:junit:4.12'
}

当我在compile 'com.airbnb.android:lottie:2.2.5'添加compile 'com.airbnb.android:lottie:2.2.5'并进行编译时。 我正在错误以下。

Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0

我现在不想更新我的SDK。 如何避免这个错误?

在您的应用程序build.gradle中

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

然后添加依赖项:

dependencies {
    def supportLibrariesVersion = '26.1.0'

    compile "com.android.support:support-compat:${supportLibrariesVersion}"
    compile "com.android.support:cardview-v7:${supportLibrariesVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibrariesVersion}"
    compile "com.android.support:gridlayout-v7:${supportLibrariesVersion}"
    compile "com.android.support:design:${supportLibrariesVersion}"
}

此外,您还必须进行以下修改以使其起作用:

compileSdkVersion 26
buildToolsVersion "26.0.1"

只是一个猜测,但可能会失败,因为appcompat-v7:26.1.0 lib(可能由lottie库使用)比您的构建工具版本新。 尝试将构建工具版本提高到26.0.1,并将sdkVersion编译到26。此外,您还尝试在旧版本中使用相同的库(编译'com.android.support:appcompat-v7:25.3.1')也可能是一个问题。

谷歌将其存储库移至新位置。 当您使用android gradle plugin> 3时,只需将其添加到您的build-script

repositories {
    google()
}

否则添加这个

repositories {
    maven {
        url "https://maven.google.com"
    }
}

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM