Weird crash in Android app, occurs in debug flavou...
# compose-android
m
Weird crash in Android app, occurs in debug flavour not release flavour! I'm just starting to convert to compose, currently putting compose functions into fragments, just as an early step. In a debug build my app crashes on startup apparently while loading my BillingManager, presumably the Android actual of the shared expected. In the release version it runs without crashing. The crash says
java.lang.NoSuchMethodError: No virtual method Int$class-BillingManager()I in class L<package>/shared/datamanagers/LiveLiterals$BillingManagerKt; or its super classes (declaration of '<package>.shared.datamanagers.LiveLiterals$BillingManagerKt' appears in /data/app/~~fzP5e5Nw7VRAFkW7ArMVJw==/<package>-4gCt-8VT8IkdbhUyQ1Uo1w==/base.apk!classes3.dex)
I have no idea where to go with this. The only real difference code between debug and release is the release version loads ACRA in attachBaseContext while debug has a stackTraceLogger in onCreate. The gradle build is very slightly different, but I've switched almost everything in debug and still get the crash... This crash doesn't occur in my previous, non-compose, version in any flavour. Any ideas for what it is or what I could look for?
s
Try disabling live literals in Android Studio (or updating to newer version where it is disabled by default) From the class name, they seem to cause the issue
m
Thanks for that @shikasd I'm on Flamingo | 2022.2.1 Patch 2 but Live Literals were enabled by default (not knowing what they were I wouldn't have changed that). Nope, makes no difference 😞
s
Weird, disabling that should turn off the related codegen :) I remember someone sharing that this setting didn't work quite right, though Could you try assembling the app directly from console (with Gradle, I assume), to verify that Studio is causing the issue here?
m
Interesting. This fails to build citing four errors. I've fixed three but it's now using the complaint that stops "Rebuild Project" in AS. It says
e: java.lang.IllegalStateException: e: Could not find "/home/mark/AndroidStudioProjects/MM4/shared/build/kotlinTransformedMetadataLibraries/commonMain/org.jetbrains.kotlinx-atomicfu-0.18.5-nativeInterop-EtwJsg.klib" in [/home/mark/.local/share/kotlin/daemon]
I have included atomicfu (albeit version 0.20.2) in my project gradle build file, even though it should be included from Kotlin plugins (I believe), but...
Just to be clear, none of these errors stop the app building and running from the UI
s
Hm, I am not sure what's the setup you are using How do you build the app from console?
m
./gradlew build assembleLocaldevice
s
It's likely doing too much, consider doing appassembleRelease, or whatever your app module is
assembleDebug, I meant :D
You can also check which command AS uses for building the app at the top of Gradle log in UI It usually says
running [targetName]
m
I'm using flavours to differentiate between types of build (mostly because different types use different websites, but partly to have different crash reporting facilities). However, I tried it with assembleDebug and it still complains about atomicfu 😞
This is with Kotlin 1.8.20
s
Hm, maybe clean build can help here, not sure
m
Err, not sure what you mean. "Clean Project" from the UI?
"Interestingly" the flavours that used to run now also crash with the main error
s
./gradlew clean
and then try to build again
m
Ok, yup. Nope. Same thing. It errors with
Task :shared:compileCommonMainKotlinMetadata FAILED
While looking for atomicfu as above. (Thank you for your help with this, btw. I appreciate it!)
s
Yeah, not sure what it is caused by
m
Fixed! I hadn't actually loaded the atomicfu plugin, just written the "implementation" line. Loading that plugin stops the crash 🤡