android - 构建失败,因为在我的应用程序上添加了新库,导致依赖关系冲突

标签 android gradle android-gradle-plugin build.gradle react-native-android

使用 npm install在我的react native上安装新的库onesignal之后--save react-native-onesignal
然后在构建应用程序时出现以下错误:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.1) from [com.android.support:cardview-v7:26.0.1] AndroidManifest.xml:25:13-35 is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override.



我知道 com.android.support:cardview-v7:26.0.1 com.android.support:support-v4:26.1.0 与我添加的该库之间存在一些冲突,但我只是不知道这是什么导致冲突以及如何解决。

由onesignal库添加的新gradle如下:
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"

    compile('com.onesignal:OneSignal:3.8.3') {
        // Exclude com.android.support(Android Support library) as the version range starts at 26.0.0
        //    This is due to compileSdkVersion defaulting to 23 which cant' be lower than the support library version
        //    And the fact that the default root project is missing the Google Maven repo required to pull down 26.0.0+
        exclude group: 'com.android.support'
        // Keeping com.google.android.gms(Google Play services library) as this version range starts at 10.2.1
    }

    testCompile 'junit:junit:4.12'
}

这是app.build.gradle的样子:
dependencies {
    compile project(':react-native-onesignal')
  compile fileTree(dir: 'libs', include: ['*.jar'])

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

  // Our dependencies
  compile 'com.android.support:appcompat-v7:26.0.1'

  // Our dependencies from ExpoView
  // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
  compile 'com.android.support:appcompat-v7:26.0.1'
  compile 'com.facebook.android:facebook-android-sdk:4.7.0'
  compile('com.facebook.android:audience-network-sdk:4.22.1') {
    exclude module: 'play-services-ads'
  }
  provided 'org.glassfish:javax.annotation:3.1.1'
  compile 'com.jakewharton:butterknife:7.0.1'
  compile 'de.greenrobot:eventbus:2.4.0'
  compile 'com.amplitude:android-sdk:2.9.2' // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
  compile 'com.squareup.picasso:picasso:2.5.2'
  compile 'com.google.android.gms:play-services-gcm:9.8.0'
  compile 'com.google.android.gms:play-services-analytics:9.8.0'
  compile 'com.google.android.gms:play-services-maps:9.8.0'
  compile 'com.google.android.gms:play-services-auth:9.8.0'
  compile 'com.google.android.gms:play-services-location:9.8.0'
  compile 'com.google.android.gms:play-services-ads:9.8.0'
  apt 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
  compile "com.raizlabs.android:DBFlow-Core:2.2.1"
  compile "com.raizlabs.android:DBFlow:2.2.1"
  compile "com.madgag.spongycastle:core:1.53.0.0"
  compile "com.madgag.spongycastle:prov:1.53.0.0"
  debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  // debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  compile 'com.facebook.device.yearclass:yearclass:1.0.1'
  compile 'commons-io:commons-io:1.3.2'
  compile 'me.leolin:ShortcutBadger:1.1.4@aar'
  compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
  compile 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
  compile 'com.yqritc:android-scalablevideoview:1.0.1'
  compile 'commons-codec:commons-codec:1.10'
  compile 'com.segment.analytics.android:analytics:4.3.0'
  compile 'com.google.zxing:core:3.2.1'
  compile 'net.openid:appauth:0.4.1'
  compile 'com.airbnb.android:lottie:2.2.0'
  compile 'io.branch.sdk.android:library:2.6.1'
  compile('io.nlopez.smartlocation:library:3.2.11') {
    transitive = false
  }
  compile 'com.android.support:exifinterface:26.0.1'
  compile 'com.squareup.okhttp3:okhttp:3.4.1'
  compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
  compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
  compile 'com.squareup.okio:okio:1.9.0'

  // Testing
  androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
  // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
  androidTestCompile 'com.android.support.test:runner:1.0.1'
  androidTestCompile 'com.android.support:support-annotations:26.0.1'
  androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
  androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
  androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'



  compile('host.exp.exponent:expoview:26.0.0@aar') {
    transitive = true
  } 
}

想法如何解决?

最佳答案

  • 将所有支持库版本更改为26.1.0
  • Play服务版本为15.0.0

  • 它应该工作。

    关于android - 构建失败,因为在我的应用程序上添加了新库,导致依赖关系冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49814899/

    相关文章:

    android - 将 0 和 1 之间的值转换为十六进制

    android - 如何开发PhoneGap android的 "Zxing"条码扫描器应用

    android - 'gradlew' 不是内部或外部命令、可运行程序或批处理文件

    android-studio - 将defs保留在单独的文件中

    java - 将Android应用程序转换为Android库时出错

    Android Studio 3.0 生成平面依赖关系树,那么我该如何阅读它

    用于 eclipse 覆盖自定义过滤器的 Android ADT v14

    Android GCM 和多个 token

    java - 'android.enableUnitTestBinaryResources' 已弃用

    android - 如何使用 `gradlew` 构建 APK 的路径和名称?