Remove obfuscation in proguard (#6067)
* Remove obfuscation in proguard for the OSS app. Fully allow it by default for enterprise ones. * Add logic to use additional customizable proguard files depending on whether the build is an enterprise one or not.
This commit is contained in:
committed by
GitHub
parent
b73e15625a
commit
fdbd7359a0
@@ -132,8 +132,23 @@ android {
|
|||||||
optimization {
|
optimization {
|
||||||
enable = true
|
enable = true
|
||||||
keepRules {
|
keepRules {
|
||||||
files.add(File(projectDir, "proguard-rules.pro"))
|
files.add(File(projectDir, "common-proguard-rules.pro"))
|
||||||
files.add(getDefaultProguardFile("proguard-android-optimize.txt"))
|
files.add(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||||
|
|
||||||
|
// Depending on whether the app flavor is enterprise or not we want to use different proguard rules.
|
||||||
|
val flavorProguardFile = if (isEnterpriseBuild) {
|
||||||
|
// Custom rules for enterprise builds
|
||||||
|
File(projectDir, "enterprise-proguard-rules.pro")
|
||||||
|
} else {
|
||||||
|
// These default rules prevent the OSS app from being obfuscated
|
||||||
|
File(projectDir, "default-proguard-rules.pro")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flavorProguardFile.exists()) {
|
||||||
|
files.add(flavorProguardFile)
|
||||||
|
} else {
|
||||||
|
logger.warn("Proguard file ${flavorProguardFile.absolutePath} does not exist")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
# For more details, see
|
# For more details, see
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Increase optimizations passes to 3
|
||||||
|
-optimizationpasses 3
|
||||||
|
|
||||||
# JNA
|
# JNA
|
||||||
-dontwarn java.awt.*
|
-dontwarn java.awt.*
|
||||||
-keep class com.sun.jna.** { *; }
|
-keep class com.sun.jna.** { *; }
|
||||||
@@ -41,7 +44,6 @@
|
|||||||
static int windowAttachCount(android.view.View);
|
static int windowAttachCount(android.view.View);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Keep LogSessionId class and related classes (https://github.com/androidx/media/issues/2535)
|
# Keep LogSessionId class and related classes (https://github.com/androidx/media/issues/2535)
|
||||||
-keep class android.media.metrics.LogSessionId { *; }
|
-keep class android.media.metrics.LogSessionId { *; }
|
||||||
-keep class android.media.metrics.** { *; }
|
-keep class android.media.metrics.** { *; }
|
||||||
@@ -66,10 +68,9 @@
|
|||||||
-dontwarn androidx.window.sidecar.SidecarWindowLayoutInfo
|
-dontwarn androidx.window.sidecar.SidecarWindowLayoutInfo
|
||||||
|
|
||||||
# Also needed after AGP 8.13.1 upgrade, it seems like proguard is now more aggressive on removing unused code
|
# Also needed after AGP 8.13.1 upgrade, it seems like proguard is now more aggressive on removing unused code
|
||||||
-keep,allowshrinking class org.matrix.rustcomponents.sdk.** { *;}
|
-keep,allowoptimization,allowshrinking class org.matrix.rustcomponents.sdk.** { *;}
|
||||||
-keep,allowshrinking class uniffi.** { *;}
|
-keep,allowoptimization,allowshrinking class uniffi.** { *;}
|
||||||
-keep,allowshrinking class io.element.android.x.di.** { *; }
|
-keep,allowoptimization,allowshrinking class io.element.android.x.di.** { *; }
|
||||||
-keepclasseswithmembernames,allowoptimization,allowshrinking class io.element.android.** { *; }
|
|
||||||
|
|
||||||
# Keep Metro classes
|
# Keep Metro classes
|
||||||
-keep,allowshrinking class dev.zacsweers.metro.** { *; }
|
-keep,allowoptimization,allowshrinking class dev.zacsweers.metro.** { *; }
|
||||||
2
app/default-proguard-rules.pro
Normal file
2
app/default-proguard-rules.pro
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Don't obfuscate anything for non-enterprise builds
|
||||||
|
-dontobfuscate
|
||||||
Reference in New Issue
Block a user