Android Question guava-26.0 - Unable to Compile the application

I'm developing an image classification Android app, but each time I try to compile it, I get an error.


Error:
B4A Version: 13.00
Parsing code.    (0.18s)
    Java Version: 19
Building folders structure.    (0.08s)
Running custom action.    (0.08s)
Compiling code.    (1.08s)
Compiling layouts code.    (0.08s)
Organizing libraries.    (0.17s)
    (AndroidX SDK)
Compiling resources    (8.58s)
Linking resources    (0.78s)
    build tools: 34.0.0, android jar: android-34
Compiling debugger engine code.    (2.90s)
Compiling generated Java code.    (5.51s)
Finding libraries that need to be dexed.    (0.02s)
Dex: C:\Android\tools\..\extras\b4a_local\unpacked-android-gif-drawable-1.2.20.androidx-63860423222456\jars\b4a_jni    (0.60s)
Dex: C:\Android\tools\..\extras\b4a_local\unpacked-android-gif-drawable-1.2.20.androidx-63860423222456\jars\classes    (1.14s)
Dex code    (7.05s)
Dex merge    Error
Error in C:\Android\tools\..\extras\b4a_local\unpacked-guava-26.0-android-63860370205197\dex_v1\guava-26.0-android.zip:classes.dex:
Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-guava-26.0-android-63860370205197\dex_v1\guava-26.0-android.zip:classes.dex, C:\Android\tools\..\extras\b4a_local\unpacked-com.google.guava-listenablefuture-63860242776000\dex_v1\com.google.guava-listenablefuture.zip:classes.dex
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Android\tools\..\extras\b4a_local\unpacked-guava-26.0-android-63860370205197\dex_v1\guava-26.0-android.zip:classes.dex
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1269)
    at com.android.tools.r8.D8.main(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Android\tools\..\extras\b4a_local\unpacked-guava-26.0-android-63860370205197\dex_v1\guava-26.0-android.zip:classes.dex
    at Version.fakeStackEntry(Version_8.3.37.java:0)
    at com.android.tools.r8.Q.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:5)
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:244)
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:90)
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:909)
    at com.android.tools.r8.internal.po.b(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:99)
    at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1041)
    at com.android.tools.r8.D8.b(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:514)
    at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1076)
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1256)
    ... 1 more
Caused by: com.android.tools.r8.internal.h: Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-guava-26.0-android-63860370205197\dex_v1\guava-26.0-android.zip:classes.dex, C:\Android\tools\..\extras\b4a_local\unpacked-com.google.guava-listenablefuture-63860242776000\dex_v1\com.google.guava-listenablefuture.zip:classes.dex
    at com.android.tools.r8.internal.X30.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:346)
    at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:232)
    at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:91)
    at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
    at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:32)
    at com.android.tools.r8.graph.q4$a.d(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:6)
    at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:264)
    at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:222)
    at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:219)
    at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:809)
    at com.android.tools.r8.D8.d(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:212)
    at com.android.tools.r8.D8.c(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:163)
    at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:906)
    ... 6 more

These are the libraries that I'm using.
Screenshot 2024-08-28 120042.png


I think this is related to the TensorFlowLite -Update. This wrapper uses Guava IO Library (guava-26.0-android.jar).

are there any solutions for this?
 
Solution
Add these three lines:
B4X:
#ExcludedLib: guava-26.0-android.jar
#AdditionalJar: com.google.guava:guava
#AdditionalJar: com.google.guava:listenablefuture

Confirm that it works and I'll update the library thread.
What happens if you add this to the main module:
B4X:
#ExcludedLib: guava-26.0-android.jar

I tried. Now I'm getting this error


Error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main2) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main2) Resume **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/io/ByteStreams;
    at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.copyToCacheFile(TensorFlowImageClassifier.java:181)
    at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.openAssetFile(TensorFlowImageClassifier.java:164)
    at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.loadModelFile(TensorFlowImageClassifier.java:81)
    at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.create(TensorFlowImageClassifier.java:58)
    at com.tillekesoft.tensorflowlite.TensorflowWrapper$1.run(TensorflowWrapper.java:51)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.io.ByteStreams" on path: DexPathList[[zip file "/data/app/com.SAFE.cyp3r-DgdR61Q8m4EsOL01pABMuA==/base.apk"],nativeLibraryDirectories=[/data/app/com.SAFE.cyp3r-DgdR61Q8m4EsOL01pABMuA==/lib/x86_64, /data/app/com.SAFE.cyp3r-DgdR61Q8m4EsOL01pABMuA==/base.apk!/lib/x86_64, /system/lib64, /system/vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 8 more
 
Upvote 0
Top