Migrating to Gradle 3.0.0: Error - D8: Program type already present

262 views Asked by At

I am migrating my Android project to Gradle 4.4 and Android Gradle plugin 3.1.2. It has a library module which depends on parceler library and defines its dependency as follows:

build.gradle of library module:

...
// parceler for serialization (https://github.com/johncarl81/parceler)
implementation "org.parceler:parceler-api:1.0.4"
annotationProcessor "org.parceler:parceler:1.0.4"
...

This seems to compile well and generates my aar file.

Further, my main app module also has a direct dependency on parceler module and contains above lines as dependencies in its build.gradle, along with above aar file.

build.gradle of main app module:

...
api(group: 'com.example.mylibrary', name: 'mylibrary', version: "1.0.7", ext: 'aar') {
    transitive = true;
    changing = true
}
// parceler for serialization (https://github.com/johncarl81/parceler)
implementation "org.parceler:parceler-api:1.0.4"
annotationProcessor "org.parceler:parceler:1.0.4"
...

Everything works until I try to generate my APK, which fails with the following error.

D8: Program type already present: org.parceler.Parceler$$Parcels$1
Task :MPCApp:transformDexArchiveWithDexMergerForRelease FAILED

When I expand my library project in Android studio, I see Parcels.class under org.parceler package. But it seems similar file is also generated by main app module under the same package which is causing the clash.

1

There are 1 answers

0
John Ericksen On

Upgrade to the latest (currently 1.1.10) - We got rid of the Parcels generated class.