Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R8 minify: Type defined multiple times

When building a signed release APK I'm getting following error:

.gradle/caches/transforms-2/files-2.1/532a317ccd54c8ae4f622faeb8b534a9/jetified-wordup-core-0.2.1-runtime.jar:de/codereddev/wordup/database/WordDao_Impl$5.class,
Type de.codereddev.wordup.database.WordDao_Impl$5 is defined multiple times:
/home/codered_dev/.gradle/caches/transforms-2/files-2.1/532a317ccd54c8ae4f622faeb8b534a9/jetified-wordup-core-0.2.1-runtime.jar:de/codereddev/wordup/database/WordDao_Impl$5.class,
/home/codered_dev/MySoundboardApp/app/build/intermediates/javac/release/classes/de/codereddev/wordup/database/WordDao_Impl$5.class

This Room DAO definition comes from a library I created myself.

Looking into the .jar file I can find this:

enter image description here

This only happens on release. I can still build and run debug without any problems.

Unfortunately I can't find the error. Hopefully anyone here might have a hint for me.

I first assumed it might be due to the fact that the library contains a standard definition of a Room database and my application using the library contains its own custom definition holding the same DAOs. So annotation processors would maybe process the DAOs twice. But I couldn't check this properly.

If it's important to know: I'm also using Koin for dependency injection.

like image 959
CodeRed Avatar asked Jul 26 '20 10:07

CodeRed


2 Answers

Unfortunately I don't exactly know the reason but I got the library working by removing the Room kaptCompiler from the library and instead only have it in the app that is using the library.

like image 63
CodeRed Avatar answered Oct 18 '22 03:10

CodeRed


This can happen if the same package is used by different module, e.g. a library and the app using the library both using org.foo.bar as package. If different packages are used, the error will go away.

like image 37
k_o_ Avatar answered Oct 18 '22 01:10

k_o_