简体   繁体   English

与项目':app'中的依赖项冲突。 app(15.0.2)和测试app(12.0.1)的已解决版本不同(可能是信号和firebase问题)

[英]Conflict with dependency in project ':app'. Resolved versions for app (15.0.2) and test app (12.0.1) differ (possibly onesignal&firebase issue)

I cant seem to build gradle for my app on Android Studio 3.0.1 (generate apk works). 我似乎无法在Android Studio 3.0.1上为我的应用程序构建gradle(生成apk工程)。 Below was the build output. 下面是构建输出。

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.google.firebase:firebase-messaging' in project ':app'. 
Resolved versions for app (15.0.2) and test app (12.0.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s

Here is the build.gradle file contents. 是build.gradle文件的内容。

UPDATE 21.8.2018: 更新21.8.2018:

I notice in the external libraries, I have a conflict 我注意到在外部库中,我有冲突

在此输入图像描述

I found out that I can generate the apk (Build APK) eventhough gradle produce the conflict error. 我发现我可以生成apk(Build APK)eventHough gradle产生冲突错误。 The way to remove gradle error is to remove/comment this line: 删除gradle错误的方法是删除/注释此行:

implementation 'com.google.android.gms:play-services-places:15.0.1'

but then APK wont compile. 但然后APK不会编译。 It used to work, I realized this problem may have happened after I had to include Firebase in another project (cordova based Android app) that used the same Android Studio. 它曾经工作,我意识到这个问题可能发生在我必须将Firebase包含在另一个使用相同Android Studio的项目(基于cordova的Android应用程序)之后。 This problem does not happen to my other colleague machine. 这个问题不会发生在我的其他同事机器上。 How do I really solve this ? 我该如何解决这个问题? Thanks 谢谢

Please post your build.gradle file. 请发布您的build.gradle文件。 But without seeing it my guess is that you have an implementation and testImplementation that have different versions for com.google.firebase:firebase-messaging 但是没有看到我的猜测是你有一个implementationtestImplementationcom.google.firebase:firebase-messaging不同版本com.google.firebase:firebase-messaging

Try to force the version of your firebase dependency using below configuration 尝试使用以下配置强制使用firebase依赖项的版本

android {
    configurations.all {
        resolutionStrategy.force 'com.google.firebase:firebase-core:16.0.1'
    }
}

It looks like a transitive dependency issue. 它看起来像一个传递依赖问题。 Both com.google.android.gms:play-services and com.onesignal:OneSignal use com.google.firebase:firebase-messaging , but they're probably importing different versions. com.google.android.gms:play-servicescom.onesignal:OneSignal使用com.google.firebase:firebase-messaging com.onesignal:OneSignal com.google.firebase:firebase-messaging ,但他们可能导入了不同的版本。 I'd recommend upgrade to use the latest versions of these libraries. 我建议升级以使用这些库的最新版本。

It seems like there are two libraries that depend on firebase-messaging library, and they're depending on different versions. 似乎有两个库依赖于firebase-messaging库,它们依赖于不同的版本。 To find out which ones they are, go to Terminal window in your Android Studio and run this command: 要找出它们是哪些,请转到Android Studio中的终端窗口并运行以下命令:

./gradlew app:dependencies ./gradlew app:依赖项

That'll show you all the dependencies in your project in a tree structure. 这将在树结构中向您显示项目中的所有依赖项。 Once you detect which libraries add the duplicate library, you can try one of these: 一旦检测到哪些库添加了重复的库,您可以尝试以下方法之一:

1) Check for the other versions of the parent dependencies in your build.gradle which both use the same version of the transitive duplicate dependency. 1)检查build.gradle中其他版本的父依赖项,它们都使用相同版本的传递重复依赖项。

2) Exclude the dependency with the lower version from the parent dependency. 2)从父依赖项中排除较低版本的依赖项。 Example: 例:

  implementation('com.example.abc:def:1.0.0') {
     exclude group: 'com.google.firebase', module: 'firebase-messaging' 
  }

3) Enforce a fixed version w/ a resolution strategy: 3)实施具有解决策略的固定版本:

configurations.all {
  resolutionStrategy { 
     force com.google.firebase:firebase-messaging:15.0.2
  }
}

Dependency OneSignal is using old version of play-service . 依赖性OneSignal正在使用旧版本play-service

You have these ways to solve this. 你有这些方法来解决这个问题。

  • Exclude play-service from OneSignal and force to use the latest- you are using. 从OneSignal中排除play-service并强制使用您正在使用的最新版本。 (As @gizembrh answer ). (正如@gizembrh回答 )。 ( I dont suggest, because OneSignal's code may crash with new play-service ) 我不建议,因为OneSignal的代码可能会因新的播放服务而崩溃
  • Download the OneSignal sdk and put that as a module in your project. 下载OneSignal sdk并将其作为模块放入项目中。 Then update OneSignal's play-service version, solve it's deprecated methods(if any). 然后更新OneSignal的播放服务版本,解决它已弃用的方法(如果有的话)。 ( Lengthy work ) 冗长的工作
  • Downgrade your play-service version as same version of OneSignal. 将您的play-service版本降级为相同版本的OneSignal。 ( The easiest I think ) 我认为最容易

I think 3rd option best suits to you. 我认为第三种选择最适合你。 Because you just need to downgrade your play-service version. 因为您只需要降级播放服务版本。 See OneSignal build.gradle play-service version 请参阅OneSignal build.gradle播放服务版本

def playServicesVersion = '12.0.0'
implementation "com.google.android.gms:play-services-places:$playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$playServicesVersion"

Also use in your project level build.gradle , use below version of google-services . 也可以在项目级build.gradle中使用,使用以下版本的google-services See OneSignal build.gradle google-services version . 请参阅OneSignal build.gradle google-services版本

classpath 'com.google.gms:google-services:4.0.1'

If you do above both changes in your gradle, you will not face this error any more. 如果您在gradle中进行了上述两项更改,则不会再出现此错误。

暂无
暂无

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

相关问题 在项目':app'中与依赖'com.google.code.gson:gson'冲突。 app(2.7)和测试app(2.8.0)的已解决版本不同 - Conflict with dependency 'com.google.code.gson:gson' in project ':app'. Resolved versions for app (2.7) and test app (2.8.0) differ 错误:与项目':app'中的依赖项'com.android.support:support-v4'发生冲突。 应用(25.3.1)和测试应用(23.1.1)的已解决版本不同 - Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (25.3.1) and test app (23.1.1) differ 与项目':app'中的依赖'com.android.support:support-annotations'冲突。 app(26.1.0)和测试app(27.1.1)的已解决版本有所不同。 - Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. 错误:在项目':app'中与依赖项'com.google.guava:guava'发生冲突。 应用(18.0)和测试应用(16.0.1)的已解决版本不同 - Error:Conflict with dependency 'com.google.guava:guava' in project ':app'. Resolved versions for app (18.0) and test app (16.0.1) differ 警告:与项目':app'中的依赖项'junit:junit'冲突。 app(4.11)和test app(4.12)的已解决版本 - Warning: Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.11) and test app (4.12) Espresso错误:与依赖项“ com.android.support:support-v4”发生冲突。 应用(24.2.0)和测试应用(23.1.1)的已解决版本不同 - Espresso Error:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (24.2.0) and test app (23.1.1) differ 与依赖'com.android.support:support-annotations'冲突。 app(23.3.0)和测试app(23.1.1)的已解决版本有所不同 - Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.1.1) differ 与依赖'com.android.support:support-annotations'冲突。 app(23.1.0)和测试app(23.0.1)的已解决版本有所不同 - Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ Gradle:应用和测试应用的已解决版本不同 - Gradle: Resolved versions for app and test app differ 应用程式和测试应用程式的Android Espresso 2.2.1解析版本不同 - Android Espresso 2.2.1 Resolved versions for app and test app differ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM