2017-09-27 109 views
0

我正在構建一個Android項目。使用以下gradle配置。一切工作正常。直到我嘗試在項目中添加lottie-android庫。庫和項目之間的Gradle依賴衝突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:[email protected]' 
    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' 
} 

當我在gradle中添加compile 'com.airbnb.android:lottie:2.2.5'並編譯。我正在低於錯誤。

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

我不想現在更新我的SDK。如何避免這個錯誤?

回答

3

在應用程序中的build.gradle

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

然後添加dependencie(S):

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" 
+0

收到此錯誤做上述更改後。 https://stackoverflow.com/questions/46443975/manifest-merger-failed-with-multiple-errors-while-updating-to-api-26-in-android/ – XoXo

+0

我已經更新了我的答案。讓我知道它是否解決了您的問題。 – Benjamin

+0

我也一樣。但是我收到了一些奇怪的錯誤。請檢查我的另一個與此有關的問題。我收到一些合併清單錯誤。 https://stackoverflow.com/questions/46443975/manifest-merger-failed-with-multiple-errors-while-updating-to-api-26-in-android/ – XoXo

1

只是一個猜測,但也許它失敗,因爲appcompat-v7:26.1.0 lib(可能由lottie庫使用)比你的構建工具版本更新。嘗試將您的構建工具版本升級到26.0.1,並將您的編譯版本sdkVersion升級到26. 另外,您還試圖在舊版本中使用相同的庫 (compile'c​​om.android.support:appcompat-v7:25.3.1 ')也可能是一個問題。

而谷歌把它的存儲庫移到了新的位置。當你使用Android插件的gradle> 3只添加到您的構建腳本

repositories { 
    google() 
} 

其他添加此

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

更新我的gradle後得到這個錯誤: https://stackoverflow.com/questions/46443975/manifest-merger-failed-with-multiple-errors-while-updating-to-api-26-in-android/ – XoXo

相關問題