Google 播放位置库:清单合并失败

Google Play Location Library: Manifest merger failed

尝试包含 Google Play 服务位置库时,出现以下错误:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value 
value=(25.4.0) from [com.android.support:design:25.4.0] 
AndroidManifest.xml:28: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 <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.

我的依赖如下:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v4:25.4.0'
    compile 'com.android.support:design:25.4.0'
    implementation "com.android.support:appcompat-v7:25.4.0"
    implementation "com.android.support:preference-v14:25.4.0"
    implementation "com.koushikdutta.ion:ion:2.+"
    implementation 'com.twilio:video-android:2.0.0-beta2'
    implementation 'com.google.android.gms:play-services-location:12.0.0'

    compile('org.simpleframework:simple-xml:2.7.+') {
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'
    }
}

我已经尝试过的:

我觉得一定有一个简单的解决办法,但我似乎找不到。谢谢你的时间。

您应该检查冲突库中的依赖项:

./gradlew app:dependencies

其中 app 是您的模块名称。

或执行以下操作(在 View the dependency tree 阅读详细信息):

  • Select视图>工具Windows>Gradle(或点击工具windows栏中的Gradle)。
  • 展开 AppName > 任务 > android 和 double-click android 依赖项。 Gradle 执行任务后,运行 window 应打开以显示输出。

快速检查您的依赖项,com.koushikdutta.ion:ion:2.+its dependencies 中使用以下内容:

compile 'com.android.support:support-v4:+'

这将获得最新版本的支持库。因此,您需要使用以下命令从中排除支持库:

implementation ("com.koushikdutta.ion:ion:2.+") {
    exclude group: 'com.android.support'
    exclude module: 'support-v4'
}

您应该尽量避免在您的依赖库版本中使用 +

确保 compileSdkVersionbuildToolsVersiontargetSdkVersionsupport libraries.

使用相同的版本

尝试下面提到的库代码:

implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.android.support:design:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:preference-v14:27.1.0'
implementation "com.koushikdutta.ion:ion:2.+"
implementation 'com.twilio:video-android:2.0.0-beta2'
implementation 'com.google.android.gms:play-services-location:12.0.0'
compile('org.simpleframework:simple-xml:2.7.+') {
    exclude module: 'stax'
    exclude module: 'stax-api'
    exclude module: 'xpp3'
}

此外,请确保 minSdkVersion 为 16 或更多,因为 twilio 库支持 minSdkVersion 16 或更多。还有一件事,compileSdkVersion 必须是 27。