修复Gradle中的依赖关系解析错误

tyu7yeag  于 2022-11-14  发布在  其他
关注(0)|答案(6)|浏览(191)

当我将okhttp 3依赖从3.4.1更新到4.1.0时,我的项目无法构建并抛出以下错误。

  1. Duplicate class org.intellij.lang.annotations.Identifier found in modules annotations-12.0.jar
  2. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  3. Duplicate class org.intellij.lang.annotations.JdkConstants found in modules annotations-12.0.jar
  4. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  5. Duplicate class org.intellij.lang.annotations.JdkConstants$AdjustableOrientation found in modules
  6. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  7. (org.jetbrains:annotations:13.0)
  8. Duplicate class org.intellij.lang.annotations.JdkConstants$BoxLayoutAxis found in modules annotations-
  9. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  10. Duplicate class org.intellij.lang.annotations.JdkConstants$CalendarMonth found in modules annotations-
  11. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  12. Duplicate class org.intellij.lang.annotations.JdkConstants$CursorType found in modules annotations-
  13. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  14. Duplicate class org.intellij.lang.annotations.JdkConstants$FlowLayoutAlignment found in modules
  15. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  16. (org.jetbrains:annotations:13.0)
  17. Duplicate class org.intellij.lang.annotations.JdkConstants$FontStyle found in modules annotations-
  18. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  19. Duplicate class org.intellij.lang.annotations.JdkConstants$HorizontalAlignment found in modules
  20. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  21. (org.jetbrains:annotations:13.0)
  22. Duplicate class org.intellij.lang.annotations.JdkConstants$InputEventMask found in modules
  23. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  24. (org.jetbrains:annotations:13.0)
  25. Duplicate class org.intellij.lang.annotations.JdkConstants$ListSelectionMode found in modules
  26. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  27. (org.jetbrains:annotations:13.0)
  28. Duplicate class org.intellij.lang.annotations.JdkConstants$PatternFlags found in modules annotations-
  29. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  30. Duplicate class org.intellij.lang.annotations.JdkConstants$TabLayoutPolicy found in modules
  31. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  32. (org.jetbrains:annotations:13.0)
  33. Duplicate class org.intellij.lang.annotations.JdkConstants$TabPlacement found in modules annotations-
  34. 12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  35. Duplicate class org.intellij.lang.annotations.JdkConstants$TitledBorderJustification found in modules
  36. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar
  37. (org.jetbrains:annotations:13.0)
  38. Duplicate class org.intellij.lang.annotations.JdkConstants$TitledBorderTitlePosition found in modules
  39. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  40. Duplicate class org.intellij.lang.annotations.JdkConstants$TreeSelectionMode found in modules
  41. annotations-12.0.jar (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  42. Duplicate class org.intellij.lang.annotations.Language found in modules annotations-12.0.jar
  43. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  44. Duplicate class org.intellij.lang.annotations.MagicConstant found in modules annotations-12.0.jar
  45. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  46. Duplicate class org.intellij.lang.annotations.Pattern found in modules annotations-12.0.jar
  47. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  48. Duplicate class org.intellij.lang.annotations.PrintFormat found in modules annotations-12.0.jar
  49. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  50. Duplicate class org.intellij.lang.annotations.PrintFormatPattern found in modules annotations-12.0.jar
  51. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  52. Duplicate class org.intellij.lang.annotations.RegExp found in modules annotations-12.0.jar
  53. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  54. Duplicate class org.intellij.lang.annotations.Subst found in modules annotations-12.0.jar
  55. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  56. Duplicate class org.jetbrains.annotations.Nls found in modules annotations-12.0.jar
  57. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  58. Duplicate class org.jetbrains.annotations.NonNls found in modules annotations-12.0.jar
  59. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  60. Duplicate class org.jetbrains.annotations.NotNull found in modules annotations-12.0.jar \
  61. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  62. Duplicate class org.jetbrains.annotations.Nullable found in modules annotations-12.0.jar
  63. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  64. Duplicate class org.jetbrains.annotations.PropertyKey found in modules annotations-12.0.jar
  65. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  66. Duplicate class org.jetbrains.annotations.TestOnly found in modules annotations-12.0.jar
  67. (com.intellij:annotations:12.0) and annotations-13.0.jar (org.jetbrains:annotations:13.0)
  68. Go to the documentation to learn how to Fix dependency resolution errors.

存在重复依赖项的问题(annotations-12.0.jar和annotations-13.0.jar),并且我的Gradle文件中存在漏洞。

  1. apply plugin: 'com.android.application'
  2. buildscript {
  3. repositories {
  4. mavenCentral()
  5. }
  6. dependencies {
  7. }
  8. }
  9. repositories {
  10. mavenCentral()
  11. }
  12. android {
  13. signingConfigs {
  14. release {
  15. keyAlias 'schoolber'
  16. keyPassword 'keystore123'
  17. storeFile file('../publish/keystore.jks')
  18. storePassword 'keystore123'
  19. }
  20. debug {
  21. keyAlias 'schoolber'
  22. keyPassword 'keystore123'
  23. storeFile file('../publish/keystore.jks')
  24. storePassword 'keystore123'
  25. }
  26. }
  27. compileSdkVersion rootProject.ext.COMPILE_SDK_VERSION
  28. buildToolsVersion rootProject.ext.TOOLS_VERSION
  29. defaultConfig {
  30. applicationId "com.schoolberpte.schoober"
  31. minSdkVersion rootProject.ext.MINIMUM_SDK_VERSION
  32. targetSdkVersion rootProject.ext.TARGET_SDK_VERSION
  33. versionCode rootProject.ext.VERSION_CODE
  34. versionName rootProject.ext.VERSION_NAME
  35. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  36. vectorDrawables.useSupportLibrary=true
  37. multiDexEnabled true
  38. }
  39. applicationVariants.all { variant ->
  40. variant.resValue "string", "version_name", variant.versionName
  41. variant.resValue "string", "version_name_string", "Version " + variant.versionName
  42. }
  43. buildTypes {
  44. release {
  45. minifyEnabled false
  46. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  47. debuggable true
  48. }
  49. }
  50. compileOptions {
  51. sourceCompatibility JavaVersion.VERSION_1_8
  52. targetCompatibility JavaVersion.VERSION_1_8
  53. }
  54. dataBinding {
  55. enabled true
  56. }
  57. packagingOptions {
  58. exclude 'META-INF/DEPENDENCIES.txt'
  59. exclude 'META-INF/LICENSE.txt'
  60. exclude 'META-INF/NOTICE.txt'
  61. exclude 'META-INF/NOTICE'
  62. exclude 'META-INF/LICENSE'
  63. exclude 'META-INF/DEPENDENCIES'
  64. exclude 'META-INF/notice.txt'
  65. exclude 'META-INF/license.txt'
  66. exclude 'META-INF/dependencies.txt'
  67. exclude 'META-INF/CONTRIBUTORS.md'
  68. exclude 'META-INF/LICENSE.md'
  69. exclude 'META-INF/MANIKEST.MF'
  70. exclude 'META-INF/rxjava.properties'
  71. }
  72. buildToolsVersion '28.0.3'
  73. }
  74. dependencies {
  75. implementation fileTree(include: ['*.jar'], dir: 'libs')
  76. androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
  77. exclude group: 'com.android.support', module: 'support-annotations'
  78. })
  79. implementation 'com.google.android.material:material:1.0.0'
  80. implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
  81. implementation 'androidx.recyclerview:recyclerview:1.0.0'
  82. implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  83. implementation 'androidx.cardview:cardview:1.0.0'
  84. implementation 'androidx.browser:browser:1.0.0'
  85. implementation 'androidx.cardview:cardview:1.0.0'
  86. implementation 'androidx.appcompat:appcompat:1.1.0'
  87. implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
  88. implementation 'io.reactivex.rxjava2:rxjava:2.1.17'
  89. implementation 'com.squareup.retrofit2:retrofit:2.6.0'
  90. implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
  91. implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
  92. implementation 'com.squareup.okhttp3:okhttp:4.1.0'
  93. implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
  94. implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'
  95. implementation 'com.google.code.gson:gson:2.8.5'
  96. testImplementation 'junit:junit:4.12'
  97. implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
  98. implementation project(':slidingmenu')
  99. implementation 'de.hdodenhof:circleimageview:3.0.0'
  100. implementation files('libs/signalr-client-sdk.jar')
  101. implementation files('libs/signalr-client-sdk-android.jar')
  102. implementation 'com.google.android.gms:play-services-maps:17.0.0'
  103. implementation 'com.google.android.gms:play-services-places:17.0.0'
  104. implementation 'com.google.android.gms:play-services-location:17.0.0'
  105. implementation 'com.facebook.android:facebook-android-sdk:4.18.0'
  106. implementation 'com.google.android.gms:play-services-auth:17.0.0'
  107. implementation 'com.facebook.rebound:rebound:0.3.4'
  108. implementation 'com.squareup.picasso:picasso:2.71828'
  109. implementation 'com.stripe:stripe-android:4.0.3'
  110. implementation 'com.code-troopers.betterpickers:library:3.0.1'
  111. implementation 'com.google.firebase:firebase-core:17.2.0'
  112. implementation 'com.google.firebase:firebase-messaging:20.0.0'
  113. implementation 'net.danlew:android.joda:2.9.9.1'
  114. implementation('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
  115. exclude group: 'com.google.android', module: 'support-v4'
  116. }
  117. implementation 'me.leolin:ShortcutBadger:1.1.10@aar'
  118. implementation 'com.sothree.slidinguppanel:library:3.4.0'
  119. implementation 'androidx.multidex:multidex:2.0.1'
  120. implementation 'com.intellij:annotations:+@jar'
  121. implementation 'commons-io:commons-io:2.4'
  122. implementation 'com.google.android.exoplayer:exoplayer:2.10.4'
  123. implementation 'com.github.vipulasri:timelineview:1.1.0'
  124. }
  125. apply plugin: 'com.google.gms.google-services'

我无法解决此错误,我已尝试明确指出注解依赖性,但它没有解决我的问题,这是我看到的medium article

quhf5bfb

quhf5bfb1#

对于另一个人来说,他们可能会到达这里。如果你使用模块冲突传递依赖,也会发生这种情况。
错误消息片段:
“在模块jetified-javaee-web-api-7.0.jar(javax:javaee-web-api:7.0)和jetified-tyrus-独立客户端-1.14.jar(org.glassfish.tyrus.bundles:tyrus-独立客户端:1.14)中发现重复的类javax.WebSocket.server.服务器端点配置”
在我的例子中,我使用的是Tyrus WebSocket。当我在'libs'文件夹中使用我的另一个库时一切都很好。在将这个库转换为一个模块后,在同一个项目中,我开始收到这个错误。
这是因为我的库使用了'javax:javaee-web-api:7.0',它的包已经在Tyrus中,在主应用程序上。由于库模块将继续需要类,我只是设置'compileOnly'而不是'implementation',阳光再次照耀。我认为将两者结合在一起,在根的'build.gradle'也会工作。

9o685dep

9o685dep2#

你的成绩单上有2个implementation 'androidx.cardview:cardview:1.0.0'
请删除其中一个,然后重新同步。

更新

也删除implementation 'com.intellij:annotations:+@jar'

u3r8eeie

u3r8eeie3#

在您的gradle中使用这条线。

  1. android.enableJetifier=true

gradle.properies

olhwl3o2

olhwl3o24#

在我的例子中,我只是忘记了kapt语法,而不是www.example.com上的实现androidx.room:room-compiler dependency,抛出了一个类似的错误

46qrfjad

46qrfjad5#

  • 构建.gradle*
  1. implementation 'com.intellij:annotations:12.0@jar'
  • 分级属性 *
  1. android.enableJetifier=true
iszxjhcz

iszxjhcz6#

在我的例子中,在注解-java 5和注解之间存在冲突。
这对我很有效:

构建.gradle(:应用程序)

  1. android {
  2. ...
  3. configurations.all {
  4. exclude group: 'org.jetbrains', module: 'annotations-java5'
  5. }
  6. }

相关问题