Open PMARZV opened 4 days ago
Thanks for reporting this!
I'm trying to reproduce the crash but for now I didn't succeed. Here are the steps I tried:
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "io.github.vinceglb.sample.compose"
packageVersion = "1.0.0"
}
// New here
buildTypes.release.proguard {
obfuscate.set(true)
}
}
}
./gradew samples:sample-compose:composeApp:packageMsi
But the app worked like expected, it didn't crash. Am I missing something?
Are you able to reproduce the crash using the sample-compose?
Packaging with Msi doesnt crash (proguardReleaseJars
gradle task doesnt seem to be called when packageMsi
is ran, so the package isnt being optimized or ofuscated, i guess). Thats why i said run the task createReleaseDistributable
(which is calling proguardReleaseJars
gradle task and crashing the sample-compose for me at least).
This is the error (edit. i forgot to mentioned that this is only happening with singlefilepicker) im getting without adding nothing in a proguard.pro file in compose-sample
and the errors above mentioned (in the first comment) come from a proguard file i was tinkering with when trying to solve the problem:
-keep class com.sun.jna.** { *; }
-keep class com.sun.jna.platform.** { *; }
# Preserve structure field order and names
-keepclassmembers class com.sun.jna.Structure {
java.util.List getFieldOrder();
}
# Ensure all fields in Structure$FFIType are preserved
-keepclassmembers class com.sun.jna.Structure$FFIType {
<fields>;
}
# Ensure all fields in io.github.vinceglb.filekit.core.platform.windows.win32.a are preserved
-keepclassmembers class io.github.vinceglb.filekit.core.platform.windows.win32.a {
<fields>;
protected java.util.List getFieldOrder();
}
but even with the bare sample you have tested it fails with the java lang string error
I'm still trying to reproduce the crash. Without creating a proguard file, I can even build sample-compose using createReleaseDistributable
on Windows and macOS due to proguard warnings.
On macOS, I manage to build and launch correctly the sample-compose by creating this proguard file:
-dontwarn kotlinx.datetime.**
-dontwarn org.slf4j.**
-keep class org.slf4j.**{ *; }
-keep class com.sun.jna.* { *; }
-keep class * implements com.sun.jna.* { *; }
But on Windows, I'm faced with more 100 000 proguard warnings. I tried the same proguard file and experiment with it but I failed to build the sample-compose app.
Are you using a proguard file to build the sample-compose app on Windows (even if it crashes at launch)?
just a proguard file with -ignorewarnings. if not it was not even working, exactly (i forgot to say it sorry). just tested your proguard file plus adding -ignorewarnings to be able to launch it on windows but it still fails when launching single file picker
Error:
Thanks for your help, I'm now able to reproduce when using proguard and obfuscate.set(true)
.
I've been trying for 3 hours, but I don't find any solution for now... I have no idea what's going on here. I'll probably try later
When creating an optimized and ofuscated release distributable in Compose Desktop, there seems to be problems with JNA. Could it be possible if you created a proguard rules file for the library?
![Captura de pantalla 2024-07-05 173458](https://github.com/vinceglb/FileKit/assets/100836358/91005b4f-aa02-4d98-bb04-cce7d5f8accd)