Reputation: 11946
I'm building a project which has two classes (A and B) that both inherit from BaseClass. Both classes, A and B, have the annotation @Parceler. When I build it for a phone with OS ver 4.1.2 (API 16), it gives me this error:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/example/BaseClass$$PackageHelper.class
If I build it for a phone with Nougat, there are no problems.
I had read about using parcelsIndex, but Parceler doesn't support with the version I'm using - 1.1.8.
Are there any fixes for this problem?
Upvotes: 4
Views: 160
Reputation: 4240
This error is caused because you're using 2 dependencies for the same library, with different version of the dependency.
For your case, i need more data, but i'll give an example that seems to explain your issue : say your project uses library x, and library x uses the dependency :
compile "com.android.support:appcompat-v7:25.3.0"
This is how your gradle looks like :
apply plugin: 'com.android.application'
android {
...
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.company.library_x:+"
compile "com.android.support:appcompat-v7:23.4.0"
}
Here's the thing, since you're using the same dependency, library_x
and you have collisions in the dependency, because you're importing version 23.4.0
and the library is using version 25.3.0
. When you build a project, all the dependencies are taken and 'downloaded', in this case, you've downloaded 2 versions of the same library and you have duplicated entries. You don't have a lot of options, but to use the same version library_x
uses, which means in your case, build your project with the latest version.
Fyi, some more info : under build->intermediates->exploded-aar->appcompat-v7->25.3.0->...class_of_the_error.class
you can actually see the value that caused the problem.
Upvotes: 1
Reputation: 11946
I was using the classes in different modules - this seemed to have caused it. While there are may be some solutions using @ParcelClass
annotation (https://github.com/johncarl81/parceler/issues/225 ?), I simply moved them to the same module, and it's building fine now.
Upvotes: 0