Issues when minifying chasm in Android using r8
@CharlieTap Thanks to your project, I've been able to run a demo android app that utilizes running a wasm file without any issues.
Today I decided to build a release version of the app and to my dismay the r8 compiler failed to successfully compile the app, crashing with null pointer exception.
chasm version: 0.9.53
AGPBI: {"kind":"error","text":"java.lang.NullPointerException","sources":[{"file":"/home/user/.gradle/caches/modules-2/files-2.1/io.github.charlietap.chasm/decoder-jvm/0.9.53/a73838c28c6ee7c126768d3c5cd714b1bca3ef0e/decoder-jvm-0.9.53.jar"}],"tool":"R8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete, position: Lio/github/charlietap/chasm/decoder/context/scope/SectionScopeKt;SectionScope(Lio/github/charlietap/chasm/decoder/context/DecoderContext;Lkotlin/Pair;)Ljava/lang/Object;, origin: /home/user/.gradle/caches/modules-2/files-2.1/io.github.charlietap.chasm/decoder-jvm/0.9.53/a73838c28c6ee7c126768d3c5cd714b1bca3ef0e/decoder-jvm-0.9.53.jar:io/github/charlietap/chasm/decoder/context/scope/SectionScopeKt.class
I tried keeping the entire chasm dependency without minification using the following proguard rule but couldn't manage to avoid the null pointer exception.
-keep class io.github.charlietap.chasm.** { *; }
-keep interface io.github.charlietap.chasm.** { *; }
-keep enum io.github.charlietap.chasm.** { *; }
Could you point me in the right direction?
Hey thanks, I'm able to reproduce this by running R8 on the build. 0.9.6 is coming sometime in the next 2 weeks and I will aim to get a fix out with that
Thank you for responding so quickly. Will be waiting for it. 👍
Just an update on this, I've reached out to the R8 team and they're giving some steer. It won't make 9.6.0 but I will do a minor release as soon as its ready
@CharlieTap thank you. Did you find out what is causing this, is it an issue with chasm or the R8? Would you link the issue tracker of R8 regarding this, I googled it but couldn't find.
Hey, the original ticket was here: https://issuetracker.google.com/issues/400746842
Its now fixed but that version of R8 will not be baked into AGP just yet, to use it you can override R8 with this:
settings.gradle.kts
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:8.8.39")
}
}
}
Thanks again. It's working fine now.
Might as well close this issue and keep a snippet of how to enable R8 in the README.md until the AGP is updated.
I'm going to leave this open until we get a version of AGP with a version of R8 > 8.8.39 and then I'll add some docs pointing to that
This was fixed in versions >= AGP 8.9.2