bj0
bj0

Reputation: 8213

proguard with applymapping produces duplicate names

I am writing an android module that is loaded into a 3rd party app as a plugin. The API is provided by a .jar which has been obfuscated by proguard and contains a mapping.txt file.

In my proguard config I have:

-dontskipnonpubliclibraryclasses
-dontshrink
-dontoptimize

-applymapping "mapping.txt"

...

The problem is, a class used only in my module gets mapped to the same name as a class used in the library .jar (but that I don't use). When they are loaded at runtime this causes a IncompatibleClassChangeError.

I can clearly see the duplicates in the produced mapping files:

mine:
timber.log.Timber -> b.a.a:

jars:
gnu.nmea.ContainsPosition -> b.a.a:

Is there any way to make proguard not reuse obfusaction names?

Upvotes: 1

Views: 2449

Answers (1)

T. Neidhart
T. Neidhart

Reputation: 6200

You should use the rule

-repackageclasses <packagename>

in your Android module. This will move all obfuscated classes into this (unique) package, avoiding name clashes.

Example: you module is named com.foo.mymodule, then you would add

 -repackageclasses com.foo.mymodule.internal

and all obfuscated classes will end up there.

Upvotes: 4

Related Questions