标签: android-guava

如何解决已存在的程序类型:com.google.common.util.concurrent.ListenableFuture?

由于以下错误,我现在的Android项目现在无法构建

AGPBI: {"kind":"error","text":"Program type already present: com.google.common.util.concurrent.ListenableFuture","sources":[{}],"tool":"D8"}
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/....
Program type already present: com.google.common.util.concurrent.ListenableFuture
Run Code Online (Sandbox Code Playgroud)

我正在使用Android工作室版本

Android Studio 3.2
Build #AI-181.5540.7.32.5014246, built on September 17, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
Run Code Online (Sandbox Code Playgroud)

以下链接不太有帮助

Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Run Code Online (Sandbox Code Playgroud)

我为触发此错误所做的更改如下: -

将我的tarke sdk version et.c从27增加到28

   compileSdkVersion = 28
   targetSdkVersion = 28
   minSdkVersion = 21
   buildToolsVersion = "28.0.2"
   supportLibVersion = "28.0.0"
Run Code Online (Sandbox Code Playgroud)

将我的kotlin版本增加到 ext.kotlin_version = …

android android-gradle-plugin android-guava android-workmanager

8
推荐指数
0
解决办法
3965
查看次数

测试 WorkManager 时无法解析 com.google.guava:listenablefuture:{strictly 1.0}

我有一个应用程序,它使用 WorkManager 执行一些计划任务,我正在一堆不同框架的帮助下对其进行测试。我正在使用 robolectric 和 androidx.work:work-testing 这似乎与这个问题有关。

我能够成功运行单元测试,但是当我尝试运行检测测试时,Calculate task graph失败了

Could not determine the dependencies of task ':myModule:mergeDebugAndroidTestResources'.
> Could not resolve all task dependencies for configuration ':myModule:debugAndroidTestRuntimeClasspath'.
   > Could not resolve com.google.guava:listenablefuture:{strictly 1.0}.
     Required by:
         project :myModule
      > Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints: 
           Dependency path 'MyApp:myModule:unspecified' --> 'androidx.work:work-testing:2.0.1' --> 'androidx.work:work-runtime:2.0.1' --> 'com.google.guava:listenablefuture:1.0'
           Constraint path 'MyApp:myModule:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: debugRuntimeClasspath uses version 1.0
           Dependency path 'MyApp:myModule:unspecified' --> …
Run Code Online (Sandbox Code Playgroud)

android robolectric android-guava android-workmanager

6
推荐指数
1
解决办法
2458
查看次数

已存在的计划类型:com.google.common.util.concurrent.internal.InternalFutureFailureAccess

我在编译项目时收到此错误.我发现那是因为Guava,以及为什么我得到这个,其他lib也使用Guava(Guava的这个组件)(也许是其他版本,或者只是重复).我找不出哪一个.我正在使用Guava进行散列,同时在记录时保存密码.我知道有必要排除它,但我不知道到底是什么以及如何.

Program type already present: com.google.common.util.concurrent.internal.InternalFutureFailureAccess


    dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.android.support:support-compat:28.0.0"
implementation 'com.amirarcane.recent-images:recentimages:2.0.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.mindorks:paracamera:0.2.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0'
implementation 'com.wdullaer:materialdatetimepicker:3.6.4'
implementation 'com.daimajia.numberprogressbar:library:1.4@aar'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
api 'com.google.guava:guava:27.0-android'
testImplementation 'junit:junit:4.12'}
Run Code Online (Sandbox Code Playgroud)

dependencies android compiler-errors guava android-guava

4
推荐指数
2
解决办法
2253
查看次数

如何解决由番石榴引起的错误:程序类型已存在:com.google.common.util.concurrent.internal.InternalFutures

AAR库已使用com.google.guava.

如果应用在其build.gradle中包含以下内容:

api 'com.google.guava:guava:27.0-android'
Run Code Online (Sandbox Code Playgroud)

构建应用程序会生成以下错误:

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: com.google.common.util.concurrent.internal.InternalFutures
Run Code Online (Sandbox Code Playgroud)

如果我不包含"api'com.google.guava:guava:27.0-android'",则可以构建应用程序,但是当它到达使用Guava方法时,它会出现java.lang.NoClassDefFoundError的运行时错误: Iterables.find

guava android-guava

4
推荐指数
2
解决办法
1982
查看次数