Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pro guard optimize flag #3408

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Conversation

AlexeyTsvetkov
Copy link
Collaborator

@AlexeyTsvetkov AlexeyTsvetkov commented Jul 25, 2023

ProGuard's optimizations are enabled by default. To disable them, set the following property via Gradle DSL:

compose.desktop {
    application {
        buildTypes.release.proguard {
            optimize.set(false)
        }
    }
}

@@ -12,7 +12,7 @@ import org.jetbrains.compose.internal.utils.notNullProperty
import org.jetbrains.compose.internal.utils.nullableProperty
import javax.inject.Inject

private const val DEFAULT_PROGUARD_VERSION = "7.2.2"
private const val DEFAULT_PROGUARD_VERSION = "7.3.2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I locallly switched to this version, I encountered other crashes. CI seems also can't build it.

It seeems switching to this version isn't easy.

Copy link

@EchoEllet EchoEllet Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I locallly switched to this version, I encountered other crashes. CI seems also can't build it.

It seeems switching to this version isn't easy.

Fixed with:

-keep class androidx.compose.runtime.** { *; }
-keep class kotlinx.coroutines.** { *; }

This will exclude Kotlinx coroutines from minimization. The bundle size will be 29.4 MB for the example desktop app on the macOS Apple silicon uber JAR file, previously 28.3 MB with the runtime error.

Tested with Compose 1.6.10, Proguard 7.5.0, and Kotlin 2.0.0 with a project created by kmp.jetbrains.com

The Kotlinx coroutines' Proguard rules seem to be a bit outdated, I couldn't get it working with Proguard without ignoring the warnings from kotlix.coroutines on blank Kotlin/JVM project on latest version of Proguard (7.5.0) and Kotlin (2.0.0)

I suggest excluding it from minimization to not have unexpected runtime errors for now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also lifting the default to 7.5.0 seems to be a must because it is the only version which is compatible with Kotlin 2.0.0.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have my own projects running that way already. My comment was meant as a hint to Jetbrains because at the moment building desktop applications with Kotlin 2.0.0 is broken by default.

@AlexeyTsvetkov AlexeyTsvetkov merged commit b67dde7 into master Jul 26, 2023
3 checks passed
@AlexeyTsvetkov AlexeyTsvetkov deleted the add-pro-guard-optimize-flag branch July 26, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants