Skip to content

Commit 17d0647

Browse files
committed
Minify App and fix App locale generation
1 parent d15436d commit 17d0647

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

app/build.gradle

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ android {
3333
}
3434
buildTypes {
3535
release {
36-
minifyEnabled false
36+
minifyEnabled true
37+
shrinkResources true
38+
zipAlignEnabled false
39+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
3740
}
3841
}
3942
sourceSets {
@@ -42,6 +45,7 @@ android {
4245
}
4346
}
4447
buildFeatures {
48+
compose true
4549
aidl true
4650
}
4751
compileOptions {
@@ -50,9 +54,8 @@ android {
5054
}
5155
kotlinOptions {
5256
jvmTarget = '17'
53-
}
54-
buildFeatures {
55-
compose true
57+
freeCompilerArgs += "-Xno-param-assertions"
58+
freeCompilerArgs += "-Xno-call-assertions"
5659
}
5760
composeOptions {
5861
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
@@ -64,10 +67,13 @@ android {
6467
jniLibs {
6568
useLegacyPackaging true
6669
}
67-
androidResources {
68-
generateLocaleConfig = true
70+
dex {
71+
useLegacyPackaging true
6972
}
7073
}
74+
androidResources {
75+
generateLocaleConfig = true
76+
}
7177
namespace 'com.github.capntrips.kernelflasher'
7278
}
7379

app/proguard-rules.pro

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# GENERAL
2+
-dontobfuscate
3+
-keepattributes Signature
4+
-keepattributes RuntimeVisibleAnnotations
5+
6+
# ANDROID INTERFACES / AIDL
7+
-keep class com.github.capntrips.kernelflasher.FilesystemService
8+
-keep class * implements android.os.IInterface
9+
-keepclassmembers class * {
10+
public static ** asInterface(android.os.IBinder);
11+
}
12+
13+
# Prevent R8 from stripping native methods used via JNI
14+
-keepclasseswithmembernames class * {
15+
native <methods>;
16+
}
17+
18+
# Keep RootShell library (libsu)
19+
-keep class com.topjohnwu.superuser.** { *; }
20+
21+
# RETROFIT2
22+
-keep interface com.github.capntrips.kernelflasher.GitHubApi { *; }
23+
-keep class retrofit2.** { *; }
24+
-dontwarn retrofit2.**
25+
26+
# ============ GSON ============
27+
-keep class com.google.gson.** { *; }
28+
-keep class com.github.capntrips.kernelflasher.AppUpdater$* { *; }
29+
30+
# Keep all fields/methods annotated with Gson's @SerializedName
31+
-keepclassmembers class * {
32+
@com.google.gson.annotations.SerializedName <fields>;
33+
}
34+
35+
# ============ KOTLIN ============
36+
-keep class kotlin.Metadata { *; }
37+
-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,Exceptions,InnerClasses,EnclosingMethod,Signature,SourceFile,LineNumberTable,*Annotation*,Deprecated,SourceDir,CompilationID,LocalVariableTable,LocalVariableTypeTable,Module*
38+
-keepclassmembers class **.AppUpdater$GitHubRelease {
39+
<fields>;
40+
}
41+
-keepclassmembers class **.AppUpdater$GitHubAsset {
42+
<fields>;
43+
}
44+
45+
# ============ COROUTINES ============
46+
-keepclassmembers class kotlinx.coroutines.BuildConfig { public static final boolean DEBUG; }
47+
-keep class kotlinx.** { *; }
48+
-dontwarn kotlinx.**
49+
50+
# ============ DOWNLOAD MANAGER & BROADCAST RECEIVER ============
51+
-keep class com.github.capntrips.kernelflasher.AppUpdater { *; }
52+
-keepclassmembers class com.github.capntrips.kernelflasher.AppUpdater { *; }
53+
54+
# Keep VectorDrawableCompat to avoid crashes or inflation errors
55+
-keep class androidx.vectordrawable.graphics.drawable.VectorDrawableCompat { *; }

0 commit comments

Comments
 (0)