programing

com.google.common.util.current 클래스가 중복됩니다.들을 수 있는모듈 guava-20.0.jar(com.google.guava:guava:20.0)에서 미래가 발견되었습니다.

linuxpc 2023. 7. 15. 09:47
반응형

com.google.common.util.current 클래스가 중복됩니다.들을 수 있는모듈 guava-20.0.jar(com.google.guava:guava:20.0)에서 미래가 발견되었습니다.

사용할 때implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'내 안에서app/build.gradle다음 오류가 발생했습니다.

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-20.0.jar (com.google.guava:guava:20.0) and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)

Go to the documentation to learn how to Fix dependency resolution errors.

내 안에 내가 가지고 있는 것도.app/build.gradle다음과 같습니다.

implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-awareness:16.0.0'
implementation 'com.google.android.gms:play-services-cast:16.2.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-iid:17.1.2'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation 'android.arch.work:work-runtime:1.0.1'
implementation 'com.android.support:multidex:1.0.3'
apply plugin: 'com.google.gms.google-services'

제가 사용하고 있는 라이브러리 중 하나에 이미 In-App Messaging 종속성에 대한 지원이 포함되어 있고 중복되는 라이브러리가 있을 수도 있습니다.감사해요.

2020년 솔루션

구글은 이 오류에 대해 알고 있기 때문에 충돌을 해결하기 위해 특별한 패키지를 만들었습니다.

에 추가합니다.build.gradle

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

이미 존재하는 프로그램 유형을 해결하는 방법: com.google.common.util.current에서 해결책을 찾았습니다.들을 수 있는미래?user2297550에서 다음과 같이 말했습니다.

나는 단지 추가했을 뿐입니다.implementation 'com.google.guava:guava:27.0.1-android'앱 그라들 파일의 마지막에 오류가 사라졌습니다.

그것이 저를 위한 해결책이었습니다.이제 이것이 있고 앱이 올바르게 컴파일됩니다.

implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'

저는 Flutter 프로젝트를 만들 때 이것을 발견했습니다.왜 그것이 못생긴 머리를 들었는지는 잘 모르겠지만, 저는 여기 있습니다.

그래서, 만약 어떤 Flutter 개발자들이 이것을 발견한다면, @Ray Li의 대답은 저에게 효과가 있었습니다.build.gradle편집할 파일은 다음에 있는 파일입니다.android/app폴더(즉,에 있는 것이 아닙니다.android폴더)를 선택합니다.

추가하기만 하면 됩니다.implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'다음과 같이 파일 끝에 있는 종속성 섹션으로 이동합니다.

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
}

build.gradle에 이 줄을 추가합니다.

    implementation 'com.google.guava:guava:27.0.1-android'

이것을 당신의 gradle 파일에 추가합니다.

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

저도 같은 문제에 직면했습니다.아래 라인을 추가했습니다.

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

하지만 또 다른 문제가 생겼어요Cannot fit requested classes in a single dex file (# methods: 89411 > 65536)이 오류를 해결하려면 아래와 같이 multiDex를 활성화해야 합니다.

defaultConfig {
    applicationId "com.techweezy.smartsync"
    minSdkVersion 19
    targetSdkVersion 29
    versionCode 5
    versionName "1.4"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true //added this line
}

그런 다음 마지막으로 아래 줄을 추가합니다.

   implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation 'androidx.multidex:multidex:2.0.1'

프로젝트에서 중복된 종속성 감소

예를 들어 많은 종속성에서 support-v4 및 appcompat-v7을 포함된 패키지로 사용하고 버전이 다를 수 있으므로 종속성 내부에서 이 패키지를 제거하고 하나의 컴파일 종속성을 생성해야 합니다.

포함된 모든 라이브러리 모듈이 제거됩니다.

android {
  configurations {
     all*.exclude module: 'appcompat-v7'
     all*.exclude module: 'support-v4'
  }
}

또는 각 종속성을 삭제하여 다음과 같은 패키지를 보다 명확하게 제거하도록 관리할 수 있습니다.

dependencies {
  implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0@aar') {//depend on your library
     transitive = true
     exclude group: 'com.android.support', module: 'appcompat-v7'
     exclude group: 'com.android.support', module: 'recyclerview-v7'
     exclude group: 'com.android.support', module: 'design'
     exclude group: 'com.android.support', module: 'support-v4'
     exclude group: 'com.squareup.retrofit2' module: 'retrofit'
     exclude group: 'com.squareup.retrofit2', module: 'retrofit'
     exclude group: 'com.google.code.gson', module: 'gson'
     exclude module: 'guava'//add this line if you have build error "found in modules guava-xxx-android.jar"
  }
}

제거된 모든 종속성은 해당 종속성을 사용하는 모든 라이브러리에 대해 맵 상자 외부에 하나의 복사본으로 선언해야 합니다.

저는 이것을 추가했고 저에게 완벽하게 일을 했습니다.

implementation 'com.google.guava:guava:27.0.1-android'
  1. 열다.build.gradle파일.

  2. 교체하지 마십시오!다음에 이 줄을 추가합니다.dependencies{}:

    implementation 'com.google.guava:guava:<version>-jre'
    

참고: 버전을 보려면 https://mvnrepository.com/artifact/com.google.guava/guava 으로 이동하여 최신 버전을 찾으십시오.jre.

이 두 가지 구현을 앱 레벨 build.gradle / app/build.gradle에 추가합니다.

implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'

저한테는 아무 것도 통하지 않았어요.마법처럼 이 문제를 해결한 유일한 방법은 디슈가링 라이브러리를 내 AGP 버전과 일치하도록 업데이트한 것입니다.

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0'

언급URL : https://stackoverflow.com/questions/56639529/duplicate-class-com-google-common-util-concurrent-listenablefuture-found-in-modu

반응형