Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions mobile/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<com.android.build.api.dsl.ApplicationExtension> {
namespace = "in.commandlinecoding.elephant"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
Expand All @@ -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"
Expand All @@ -37,12 +36,14 @@ android {
}
}

kotlin {
flutter {
source = "../.."
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}

flutter {
source = "../.."
}
dependencies {}
25 changes: 14 additions & 11 deletions mobile/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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(...);
Expand Down
3 changes: 2 additions & 1 deletion mobile/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}

subprojects {
project.evaluationDependsOn(":app")
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
}
Loading