diff --git a/mobile/android/app/build.gradle.kts b/mobile/android/app/build.gradle.kts index 9d77a46..7629e8b 100644 --- a/mobile/android/app/build.gradle.kts +++ b/mobile/android/app/build.gradle.kts @@ -1,10 +1,10 @@ plugins { id("com.android.application") - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") + id("org.jetbrains.kotlin.android") } -android { +configure { namespace = "in.commandlinecoding.elephant" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion @@ -24,11 +24,10 @@ android { buildTypes { getByName("release") { - // Signing with the debug keys for now, so `flutter run --release` works. signingConfig = signingConfigs.getByName("debug") - isMinifyEnabled = true isShrinkResources = true + proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" @@ -37,12 +36,14 @@ android { } } -kotlin { +flutter { + source = "../.." +} + +tasks.withType().configureEach { compilerOptions { - jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } } -flutter { - source = "../.." -} \ No newline at end of file +dependencies {} \ No newline at end of file diff --git a/mobile/android/app/proguard-rules.pro b/mobile/android/app/proguard-rules.pro index b8fa987..9c9cda0 100644 --- a/mobile/android/app/proguard-rules.pro +++ b/mobile/android/app/proguard-rules.pro @@ -1,40 +1,43 @@ -# 1. RETAIN CORE METADATA (Required for debugging and stack traces) +# 1. RETAIN CORE METADATA (Required for clean crash logs, stack traces, and reflection) -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod,SourceFile,LineNumberTable -keepattributes RuntimeVisibleAnnotations -# 2. PROTECT YOUR DATA MODELS (Strictly restricted to your package) -# Only keep classes inside your own 'models' package. -# Do not keep everything globally (which was insecure). +# 2. PROTECT DATA MODELS & SERIALIZATION SCHEMA (Restricted precisely to your package) +# Keeps data models intact to prevent broken chats or missing message properties in release packages -keep class in.commandlinecoding.elephant.models.** { *; } -# Safely handle JSON conversion methods +# Safely preserve custom JSON serialization methods used by incoming/outgoing pipelines -keepclassmembers class in.commandlinecoding.elephant.models.** { public static *** fromJson(...); public *** toJson(...); } -# 3. NETWORK FRAMEWORK PROTECTION -# Dio requires internal fields to handle interceptors/requests correctly +# 3. NETWORK FRAMEWORK PROTECTION (Preserves HTTP & Persistent WebSocket Engines) +# Dio requires internal fields to handle interceptors, token rotations, and request configurations correctly -keep class dio.** { *; } -dontwarn dio.** # WebSockets require keeping the internal message stream/channel logic -keep class web_socket_channel.** { *; } -dontwarn web_socket_channel.** + +# Retain Gson serialization references if used by native plugin drivers -keep class com.google.gson.** { *; } +-dontwarn com.google.gson.** -# 4. FLUTTER ENGINE INTEGRATION (Minimized scope) -# Keep only the specific plugin/embedding classes required for initialization +# 4. FLUTTER ENGINE & NATIVE PLUGINS INTEGRATION (Minimized optimization scope) +# Keep the core embedding engine classes required for application initialization -keep class io.flutter.embedding.** { *; } -keep class io.flutter.plugin.** { *; } -keep class io.flutter.util.** { *; } -keep class io.flutter.view.** { *; } -# 5. PLAY CORE SILENCING (Keeps the build stable) +# 5. FOSS COMPLIANCE: PLAY CORE HOOKS SILENCING +# Tells R8 to safely ignore missing Google Play binary symbols without packing non-free SDKs -dontwarn com.google.android.play.core.** -dontwarn io.flutter.embedding.engine.deferredcomponents.** -# 6. SECURITY: Remove unnecessary logging in release builds +# 6. APP SECURITY & PERFORMANCE: Remove debugging logs from the release binary -assumenosideeffects class android.util.Log { public static int v(...); public static int d(...); diff --git a/mobile/android/build.gradle.kts b/mobile/android/build.gradle.kts index dbee657..441eb71 100644 --- a/mobile/android/build.gradle.kts +++ b/mobile/android/build.gradle.kts @@ -15,10 +15,11 @@ subprojects { val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) project.layout.buildDirectory.value(newSubprojectBuildDir) } + subprojects { project.evaluationDependsOn(":app") } tasks.register("clean") { delete(rootProject.layout.buildDirectory) -} +} \ No newline at end of file