Closed SudoDios closed 2 weeks ago
Hi @SudoDios ! Do you have a reproducer that can be shared here? Did you change anything else besides Compose version? perhaps kotlin version? gradle version?
https://github.com/JetBrains/compose-multiplatform/issues/3765
What if you add -keep class proguard.optimize.gson.** { *; }
rule?
Hi bro.
I just changed the compose version.
The build is done and I get this after execution.
More complete error:
Exception in thread "main" java.lang.NoClassDefFoundError: proguard/optimize/gson/_OptimizedJsonWriter at androidx.compose.ui.scene.ComposeSceneMediator.<clinit>(Unknown Source) at androidx.compose.ui.scene.ComposeContainer.<init>(Unknown Source) at androidx.compose.ui.scene.ComposeContainer.<init>(Unknown Source) at androidx.compose.ui.awt.ComposeWindowPanel.<init>(Unknown Source) at androidx.compose.ui.awt.ComposeWindow.<init>(Unknown Source) at androidx.compose.ui.awt.ComposeWindow.<init>(Unknown Source) at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Unknown Source) at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Unknown Source) at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Unknown Source) at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Unknown Source) at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(Unknown Source) at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(Unknown Source) at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Unknown Source) at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Unknown Source) at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Unknown Source) at androidx.compose.runtime.CompositionImpl.applyChanges(Unknown Source) at androidx.compose.runtime.Recomposer.composeInitial$runtime(Unknown Source) at androidx.compose.runtime.CompositionImpl.composeInitial(Unknown Source) at androidx.compose.runtime.CompositionImpl.setContent(Unknown Source) at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Unknown Source) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source) at kotlinx.coroutines.DispatchedTask.run(Unknown Source) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: proguard.optimize.gson._OptimizedJsonWriter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 35 more
i add this -keep class proguard.optimize.gson.** { *; }
to proguard roles, but the problem was not solved
Do you have a reproducer that can be shared here?
Unfortunately, I cannot share anything from this project. However, I am currently using the previous version of compose multiplatform until this problem is solved
I see.
Given that the issue was noticed before even in 1.5.2 - https://github.com/JetBrains/compose-multiplatform/issues/3765, I think it's worth trying to ask/report it to Proguard.
Or pehaps try to use a newer Proguard version instead of a default - https://github.com/JetBrains/compose-multiplatform/blob/master/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt#L20
But this problem occurred after the update to 1.6.0 (for me). Is this from proguard? I am using proguard version 7.4.1.
Compose itself doesn't use Gson and proguard.optimize.gson._OptimizedJsonWriter
, so I suppose the new Compose version (the changes in it) rather made the proguard issue more prominent.
I looked into the recent changes in the classes shown in your stacktrace. Could you please try 1.6.0-rc02 version? Note: even if it works, the changes between rc02 and stable 1.6.0 do not have any problem with gson. It would just mean that different code is processed by Proguard leading to a different outcome.
OK, I will take a test and tell you the result
The problem still exists on version 1.6.0-rc02
The problem still exists on version 1.6.0-rc02
Is the stacktrace identical to the previous one? What about 1.6.0-beta01?
Yes, it is the same as the previous one. There is also a problem with version 1.6.0-beta01.
Another thing to try is:
compose.desktop {
application {
buildTypes.release.proguard {
optimize.set(false) // disable te optimizations completely
}
}
}
Or to configure -optimizations
manually (exclude an optimization for gson):
https://www.guardsquare.com/manual/configuration/optimizations
Do I understand correctly that it crashes right after the app starts? Do you use Gson during app initialization? If yes, is it possible to minimize the app start logic so it's still crashes but you could share a reproducer/snippet?
I think further it's worth to reach out to proguard. But an issue reproducer would be needed.
It's ok if full optimizations are disabled (how can I disable only gson optimizations ?).
Do I understand correctly that it crashes right after the app starts?
Yes
Do you use Gson during app initialization?
No
I am busy now, but I will help when I have time
how can I disable only gson optimizations
I'm not faimilar with details. But it's described here https://www.guardsquare.com/manual/configuration/optimizations
I found this but I don't know if it just disables gson optimization or everything
-optimizations !library/gson
I think this problem can be solved like this for now and I can use version 1.6.*
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug
All things is good when i'm in version 1.5.11. but i migrate to version 1.6.0 and proguard show this error on release :
Caused by: java.lang.ClassNotFoundException: proguard.optimize.gson._OptimizedJsonWriter
Affected platforms
Versions
What does this migration have to do with proguard and gson? Because I did not change the version of gson and proguard.