0

I am encountering an issue related to R8 ofuscation in my app application. During the build process, I receive the following error message:

AGPBI: {"kind":"warning","text":"The following library types, prefixed by java., are present both as library and non-library classes: java.util.LinkedHashMap, java.util.HashMap, java.util.AbstractMap, java.util.AbstractList, java.util.AbstractCollection, java.util.IdentityHashMap, java.util.ArrayList, java.util.LinkedList, java.util.Hashtable, java.util.concurrent.ConcurrentLinkedQueue, java.util.AbstractQueue, java.util.Vector, java.util.HashSet, java.util.AbstractSet, java.util.WeakHashMap", "sources":[{}],"tool":"R8"}
AGPBI: {"kind":"error","text":"Library class java.util.LinkedHashMap implements program class java.util.Map", "sources":[{}],"tool":"R8"}
AGPBI: {"kind":"error","text":"Library class java.util.HashMap implements program class java.util.Map", "sources":[{}],"tool":"R8"}

Screenshot about the build process enter image description here

Any know how I can fix the problem ?

I tried to set proguard rules for keeping package name but the error persist

I use this command for keeping clases

-keep class java.io.UncheckedIOException { *; }
-keep class java.lang.Iterable { *; }
-keep class java.time.Clock { *; }
-keep class java.time.DateTimeException { *; }
-keep class java.util.LinkedHashMap { *; }
-keep class java.util.Map { *; }
-keep class java.util.IdentityHashMap { *; }
-keep class java.util.LinkedHashMap implements java.util.Map

1 Answers1

0

This problem normmaly occurs when there is a circular dependency, in my case to solve my problem,

First: I tried to comment each module and then build the project. After try it for a long time (around 2 days), I finally identify that some module was causing this problem.

-> Feature register and login, home, recharges, myqr were those module which were causing this problem

implementation project(':feature-onboarding')
implementation project(':feature-login')
implementation project(':feature-history')
implementation project(':feature-registro')
implementation project(':feature-shopping-qr')
implementation project(':feature-myqr')
implementation project(':feature-home')
implementation project(':feature-help')
implementation project(':feature-promotions')
implementation project(':feature-transactions')
implementation project(':feature-profile')
implementation project(':feature-recharges')
implementation project(':common')
implementation project(':domain')
implementation project(':data')
implementation project(':usecases')
implementation project(':framework:imagemanager')
implementation project(':framework:databasemanager')
implementation project(":framework:security")
implementation project(":framework:qrmanager")

2: Second, I focus on one module which has less code than others, and then I analize each dependencies on that module 3. I Tried to comment dependencies which wasnt using on that module, and build the project every time I made a comment or changes 4. Finnaly I identify this library which was causing the problem:

    def desugaringVersion = "1.1.5"

coreLibraryDesugaring:"com.android.tools:desugar_jdk_libs:$desugaringVersion",

I remove this dependecy for all modules , and finally it build the project without problems. (This library was added by other developer who was at the beggining of the project, Im not sure what was the porpuse of this library but as we didnt use it, I removed it)

  • See https://developer.android.com/studio/write/java8-support#library-desugaring for information on the `coreLibraryDesugaring` dependency. Was `com.android.tools:desugar_jdk_libs:$desugaringVersion` also present as an `implementation` dependency, which might explain the issue. Also note that having `-keep` rules on classes in the `java` namespace currently has no effect. – sgjesse Jul 24 '23 at 14:05