Mike Dawson
02/01/2024, 9:00 AMOleksandr Karpovich [JB]
02/01/2024, 9:19 AMcompose.desktop {
application {
buildTypes.release.proguard {
version.set("7.4.2") // for example
}
}
}
Mike Dawson
02/01/2024, 9:20 AMMike Dawson
02/01/2024, 9:24 AMOleksandr Karpovich [JB]
02/01/2024, 9:24 AMMike Dawson
02/01/2024, 9:26 AMMike Dawson
02/01/2024, 9:28 AMMichael Paus
02/01/2024, 10:20 AMMike Dawson
02/01/2024, 11:02 AMMike Dawson
02/01/2024, 11:19 AMMike Dawson
02/01/2024, 11:20 AMMichael Paus
02/01/2024, 11:29 AMkotlin.version=1.9.22
agp.version=8.2.0
compose.version=1.6.0-dev1397
and built a fairly large application (compared to the various demos floating around) with it, which supports macOS (X86 & ARM), Windows and Linux. I also just upgraded to version 7.4.2 and did not notice any problems (if you don’t count the tens of thousands of notes and warnings that you get from ProGuard).Mike Dawson
02/01/2024, 11:30 AMMike Dawson
02/01/2024, 11:30 AMMichael Paus
02/01/2024, 11:31 AMMichael Paus
02/01/2024, 11:41 AMMike Dawson
02/01/2024, 11:58 AMMike Dawson
02/01/2024, 12:06 PMMichael Paus
02/01/2024, 1:40 PMbuildTypes.release.proguard {
obfuscate.set(false)
optimize.set(false)
version.set("7.4.0")
}
setup your example works perfectly. I have noticed previously that optimization causes nothing but problems on desktop, so I always switch it off.Mike Dawson
02/01/2024, 1:40 PMMike Dawson
02/01/2024, 1:41 PMMike Dawson
02/01/2024, 1:41 PMMichael Paus
02/01/2024, 1:46 PMMichael Paus
02/01/2024, 1:51 PMJames Hamilton
02/01/2024, 2:20 PMclass/enum/unboxing
optimization which you can disable with -optimizations !class/enum/unboxing
(https://github.com/Guardsquare/proguard/issues/349)
There is different issue when disabling that specific optimization (not all VerifyErrors have the same cause) in one of the androidx.compose
classes.
You can also provide more targeted config than completely disabling optimizations, for example excluding classes from optimization that are causing issues:
-keep,includecode,allowobfuscation,allowshrinking class androidx.compose.runtime.SnapshotStateKt** { *; }
Your sample works for me if you add the following to the compose-desktop.pro
config:
-optimizations !class/enum/unboxing
-keep,includecode,allowobfuscation,allowshrinking class androidx.compose.runtime.SnapshotStateKt** { *; }
You'll also need to tell the Compose build to use the config in the Gradle file:
compose.desktop {
application {
mainClass = "MainKt"
buildTypes.release.proguard {
obfuscate.set(false)
version.set("7.4.2")
// Add this line
configurationFiles.from(project.file("compose-desktop.pro"))
}
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "com.ustadmobile.pgvt"
packageVersion = "1.0.0"
}
}
}
Michael Paus
02/01/2024, 2:40 PMJames Hamilton
02/01/2024, 3:01 PM-optimizations
option: the available optimizations are listed here https://www.guardsquare.com/manual/configuration/optimizations
In the sample in the comment above, in terms of classes removed: the shrinking step on it's own removes a lot of the unused classes:
Removing unused program classes and class elements...
Original number of program classes: 8964
Final number of program classes: 4397
Then after 1 optimization pass, some more are removed:
Removing unused program classes and class elements...
Original number of program classes: 4397
Final number of program classes: 4226
If you do another pass (-optimizationpasses 2
), a few more are removed:
Removing unused program classes and class elements...
Original number of program classes: 4226
Final number of program classes: 4192
Mike Dawson
02/01/2024, 5:55 PMMichael Paus
02/01/2024, 6:23 PM