icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.08k stars 120 forks source link

java.lang.NoSuchFieldError with Android Gradle Plugin 8.3.0 #652

Open Faltenreich opened 7 months ago

Faltenreich commented 7 months ago

My project (link) crashes on start with the following exception after upgrading from Android Gradle Plugin 8.2.2 to 8.3.0, using version 0.23.0 of moko-resources:

FATAL EXCEPTION: main
Process: com.faltenreich.diaguard.beta, PID: 11114
java.lang.NoSuchFieldError: No static field tags of type I in class Lcom/faltenreich/diaguard/R$string; or its superclasses (declaration of 'com.faltenreich.diaguard.R$string' appears in /data/app/~~tI_khR_YrWC42LNPOtVWDQ==/com.faltenreich.diaguard.beta-8GoEXUJtIXrqQCR5je7ZxQ==/base.apk!classes17.dex)
at com.faltenreich.diaguard.MR$strings.<clinit>(MR.kt:382)

Thanks for any upcoming help and thank you for this awesome library, it is much appreciated!

Alex009 commented 7 months ago

please try 0.24.0 alpha

Faltenreich commented 7 months ago

Unfortunately 0.24.0-alpha-5 leads to the same problem.

ExNDY commented 6 months ago

@Faltenreich Hi, I can't find in your link moko-resources for check, and github can't find any mentions moko in your project, can u create brach with reproducer of your problem, or send sample?

zt64 commented 3 months ago

@ExNDY I'm also encountering this error message. It happens when the Android gradle plugin is set to version 8.3.0 or higher. 8.2.2 is the last version that works

ExNDY commented 3 months ago

@zt64 Hi, maybe u can send reproducer? Because i'm have same projects with 8.3+ and no problem with plugin.

zt64 commented 3 months ago

@ExNDY

I've been trying to make a reproducer but I can't get it to produce the bug. However, in my own project I managed to fix it

At first I had the namespace in the android plugin and resources package set to the same package as all my code was in. I changed the resources package to its own package and the crash no longer occurs

zt64 commented 3 months ago

@ExNDY Worked on it some more and got a working reproducer project. https://github.com/zt64/moko-resources-bug If I have the resources inside the common module then the crash doesnt occur, it only occurs when its in its own module

ExNDY commented 3 months ago

@zt64 Hi, I'm clearly understand problem with the same package of namespace? We can't detect this inside of plugin, because that work in Android Gradle plugin. But i think, we need add in readme info about separate namespace for all modules.