gradle 在模块guava-26.0-android.jar和guava-jdk5-17.0.jar中发现重复的类

iyfamqjs  于 2023-11-18  发布在  Android
关注(0)|答案(2)|浏览(154)

参考文档,了解如何修复依赖解析错误。

* 在模块guava-26.0-android.jar(com. google. guava:guava:26.0-android)和guava-jdk5-17.0.jar(com. google. guava:guava-jdk5:17.0)中发现重复的类 *

我最初做了这个项目,使用谷歌的Cloud Vision API,一切都很好。但现在我无法解决这个依赖,这是集成Firestore所必需的。

  1. implementation 'com.google.firebase:firebase-firestore:21.4.3'

字符串
我已经尝试

  1. implementation 'com.google.firebase:firebase-firestore:21.4.3' exclude module: 'com.google.gauva:gauva-jdk5:17.0'


  1. configurations {
  2. implementation.exclude module:'gauva-jdk5'
  3. all*.exclude group: 'com.google.guava', module: 'listenablefuture'
  4. }


  1. implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
  2. implementation 'com.google.guava:guava:26.0-android'


  1. android.useAndroidX=true//causes lot of errors, tried refactoring, but core error remained
  2. android.enableJetifier=true//no effect


正如StackOverflow,GitHub等上的大多数其他帖子所建议的那样。我也尝试过多次清理和构建。但到目前为止似乎没有任何工作。包括Firestore实现是经过验证的原因。应用程序build. gradle是

  1. apply plugin: 'com.android.application'
  2. apply plugin: 'com.google.gms.google-services'
  3. android {
  4. compileSdkVersion 29
  5. buildToolsVersion "29.0.2"
  6. defaultConfig {
  7. applicationId "com.google.sample.cloudvision"
  8. minSdkVersion 24
  9. targetSdkVersion 29
  10. versionCode 1
  11. versionName "1.0"
  12. }
  13. buildTypes {
  14. release {
  15. minifyEnabled false
  16. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  17. }
  18. buildTypes.each {
  19. it.buildConfigField 'String', 'API_KEY', "\"AIzaSyCuSEBxcK9n6_ojdCo6uUDFALdZL2w024Y\""
  20. }
  21. }
  22. compileOptions {
  23. sourceCompatibility JavaVersion.VERSION_1_8
  24. targetCompatibility JavaVersion.VERSION_1_8
  25. }
  26. configurations {
  27. implementation.exclude module:'gauva-jdk5'
  28. all*.exclude group: 'com.google.guava', module: 'listenablefuture'
  29. }
  30. }
  31. dependencies {
  32. implementation 'com.android.support:support-annotations:28.0.0'
  33. implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  34. implementation 'android.arch.lifecycle:extensions:1.1.1'
  35. implementation fileTree(include: ['*.jar'], dir: 'libs')
  36. implementation 'com.google.firebase:firebase-firestore:21.4.3' exclude module: 'com.google.gauva:gauva-jdk5:17.0'
  37. testImplementation 'junit:junit:4.12'
  38. //noinspection GradleCompatible
  39. implementation 'com.android.support:appcompat-v7:27.0.2'
  40. //noinspection GradleCompatible
  41. implementation 'com.android.support:design:27.0.2'
  42. implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
  43. implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
  44. implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0' exclude module: 'com.google.gauva:gauva-jdk5:17.0'
  45. // implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
  46. // implementation 'com.google.guava:guava:26.0-android'
  47. }


项目build.gradle是

  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. buildscript {
  3. repositories {
  4. jcenter()
  5. maven {
  6. url 'https://maven.google.com/'
  7. name 'Google'
  8. }
  9. google()
  10. }
  11. dependencies {
  12. classpath 'com.android.tools.build:gradle:3.6.3'
  13. classpath 'com.google.gms:google-services:4.3.3'
  14. // NOTE: Do not place your application dependencies here; they belong
  15. // in the individual module build.gradle files
  16. }
  17. }
  18. allprojects {
  19. repositories {
  20. jcenter()
  21. mavenCentral()
  22. maven {
  23. url 'https://maven.google.com/'
  24. name 'Google'
  25. }
  26. }
  27. }
  28. task clean(type: Delete) {
  29. delete rootProject.buildDir
  30. }


初始错误日志如下所示
在模块core-1.0.0-runtime.jar中发现重复的类android.support.v4.app.INotificationSideChannel(androidx. core:core:1.0.0)和support-compat-27.0.2-runtime.jar(www.example.com:support-compat:27.0.2)在模块core-1.0中发现重复的类android.support.v4.app.INotificationSidebookel$Stub.0-runtime.jar(androidx. core:core:1.0.0)和support-compat-27.0.2-runtime.jar(www.example.com:support-compat:27.0.2)在模块核心中发现重复的类android.support.v4.app.INotificationSideProxy el$Stub$Proxy---@.0.0-runtime.jar(androidx. core:core:1.0.0)和support-compat-27.0.2-runtime.jar(www.example.com:support-compat:com.android.support 27.0.2)在模块core-1.0.0-runtime.jar(androidx. core:core:1.0.0)和support-compat-27.0.2-runtime.jar(www.example.com:support-compat:com.android.support 27.0.2)在模块core-1.0.0-runtime.jar(androidx. core:core:1.0.0)和support-compat-27.0.2-runtime.jar(www.example.com:support-compat:com.android.support(com. google. guava:guava:26.0-android)和guava-jdk5-17.0.jar(com. google. guava:guava-jdk5:17.0)在模块guava-26.0-android.jar中找到重复的类com. google. common. annotations. Gwt Compatiblecom.android.support(com. google. guava:guava-jdk5:17.0)重复的类com. google. common. annotations. Gwt在模块guava-26.0-android.jar中发现不兼容com.android.support(com. google. guava:guava-jdk5:17.0)在模块guava-26.0-android.jar中找到重复的类com. google. common. annotations. VisibleForTesting(com. google. guava:guava:26.0-android)和guava-jdk5-17.0.jarcom.android.support(com. google. guava:guava:26.0-android)和guava-jdk5-17.0.jar(com. google. guava:guava-jdk5:17.0)在模块guava-26.0-android.jar中发现重复的类com. google. common. base. AbstractIteratorcom.android.support(com. google. guava:guava-jdk5:17.0)在模块guava-26.0-android.jar中发现重复的类com.google.common.base.AbstractIterator$1com.android.support
gradle属性-> 5.6.4

nwnhqdif

nwnhqdif1#

也许已经太晚了。不过,我正在给你写一个问题的答案。
我也有同样的问题。我使用的是Youtube数据API v3。经过几次搜索和看到Stackoverflow的答案,我混合了所有的,不知何故它工作了!!
这就是我所做的一切,它起作用了。
1.添加 * 配置 * 到应用程序级别build.gradle文件。如下所示

  1. configurations {
  2. implementation.exclude module:'guava-jdk5'
  3. all*.exclude group: 'com.google.guava', module: 'listenablefuture'
  4. }

字符串
1.在依赖块中添加了这两行

  1. implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
  2. implementation 'com.google.guava:guava:31.1-android'


1.在YouTube数据所需的依赖项中,我有API,

  1. exclude group:'com.google.guava'


就像下面

  1. implementation ('com.google.api-client:google-api-client-android:1.22.0') {
  2. exclude group: 'org.apache.httpcomponents'
  3. exclude group:'com.google.guava'
  4. }
  5. implementation ('com.google.apis:google-api-services-youtube:v3-rev183-1.22.0') {
  6. exclude group: 'org.apache.httpcomponents'
  7. exclude group:'com.google.guava'
  8. }


如果你愿意,你可以在GitHub gist上查看我的整个build.gradle文件here
Thank you:-)

展开查看全部
krcsximq

krcsximq2#

我通过在我的应用程序级别gradle configurations { implementation.exclude module:'guava-jdk5' }中添加下面的行解决了这个错误

相关问题