From 36f28acda79ff52374464dec2b3e4b99ce1bb417 Mon Sep 17 00:00:00 2001 From: Luca Bretting Date: Wed, 18 Dec 2024 00:38:19 +0100 Subject: [PATCH] build: enable r8 compiler, fix issue crashing the backend If you have a broken config, you need to delete it to stop the backend from crashing! Signed-off-by: Luca Bretting --- frontend/README.md | 12 +++++++++++- frontend/app/build.gradle.kts | 5 +++-- frontend/app/proguard-rules.pro | 5 ++++- .../ziofa/bl/configuration/ConfigurationManager.kt | 5 +++++ frontend/gradle/libs.versions.toml | 9 ++++++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index c73cda63..27e1839d 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -26,4 +26,14 @@ To automatically update all dependencies, run ### Format and check formatting Format `./gradlew combinedFormat`
-Check: `./gradlew ktfmtCheck` \ No newline at end of file +Check: `./gradlew ktfmtCheck` + +## Troubleshooting +### The frontend crashes +Make sure the backend is running or that you are running a mocked version. +If you are running a release, check for MethodNotFoundException etc., these errors are most likely +caused by R8/ProGuard removing used classes. +Quickfix: Use the debug build type. + +### The backend and frontend crashes +Delete the local configuration to make sure it does not contain outdated entries. \ No newline at end of file diff --git a/frontend/app/build.gradle.kts b/frontend/app/build.gradle.kts index 42537483..7b5079ab 100644 --- a/frontend/app/build.gradle.kts +++ b/frontend/app/build.gradle.kts @@ -45,7 +45,7 @@ android { buildTypes { release { - isMinifyEnabled = false + isMinifyEnabled = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" @@ -106,7 +106,8 @@ dependencies { implementation(libs.vico.compose.m2) implementation(libs.vico.compose.m3) implementation(libs.vico.core) - + implementation(libs.arrow.core) + implementation(libs.arrow.fx.coroutines) detektPlugins(libs.detekt.compose.rules) } diff --git a/frontend/app/proguard-rules.pro b/frontend/app/proguard-rules.pro index 8ab8d872..143742a1 100644 --- a/frontend/app/proguard-rules.pro +++ b/frontend/app/proguard-rules.pro @@ -22,4 +22,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile +-keep class com.sun.jna.** { *; } +-dontwarn java.awt.** +-keep class uniffi.** { *; } \ No newline at end of file diff --git a/frontend/app/src/main/java/de/amosproj3/ziofa/bl/configuration/ConfigurationManager.kt b/frontend/app/src/main/java/de/amosproj3/ziofa/bl/configuration/ConfigurationManager.kt index 281a8bbe..85f4f737 100644 --- a/frontend/app/src/main/java/de/amosproj3/ziofa/bl/configuration/ConfigurationManager.kt +++ b/frontend/app/src/main/java/de/amosproj3/ziofa/bl/configuration/ConfigurationManager.kt @@ -40,6 +40,11 @@ class ConfigurationManager(val clientFactory: ClientFactory) : override val localConfiguration = _localConfiguration + .map { + if (it is ConfigurationUpdate.Valid) { + it.copy(it.configuration.copy(jniReferences = null)) + } else it + } // TODO remove this once the backend has integrated setting this feature .onEach { Timber.i("local configuration updated $it") } .map { it ?: ConfigurationUpdate.Unknown } diff --git a/frontend/gradle/libs.versions.toml b/frontend/gradle/libs.versions.toml index a862bc01..2693f3ab 100644 --- a/frontend/gradle/libs.versions.toml +++ b/frontend/gradle/libs.versions.toml @@ -6,10 +6,11 @@ [versions] accompanistDrawablepainter = "0.36.0" activityCompose = "1.9.3" -agp = "8.7.2" +agp = "8.7.3" +arrow = "1.2.4" benmanes-versions = "0.51.0" -compose-navigation = "2.8.4" -composeBom = "2024.11.00" +compose-navigation = "2.8.5" +composeBom = "2024.12.01" coreKtx = "1.15.0" cyclonedx = "1.10.0" detekt = "1.23.7" @@ -43,6 +44,8 @@ androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" } +arrow-fx-coroutines = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" } detekt-compose-rules = { module = "com.twitter.compose.rules:detekt", version.ref = "detektRulesVersion" } jackwharton-timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }