Optimize apk size (#263)
This commit is contained in:
parent
490aeae95d
commit
cb5940bc1a
|
|
@ -81,7 +81,8 @@ android {
|
||||||
named("release") {
|
named("release") {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
signingConfig = signingConfigs.named("debug").get()
|
||||||
|
proguardFiles("proguard-rules.pro")
|
||||||
}
|
}
|
||||||
named("debug") {
|
named("debug") {
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
|
|
@ -90,17 +91,36 @@ android {
|
||||||
}
|
}
|
||||||
applicationVariants.all {
|
applicationVariants.all {
|
||||||
outputs.map { it as BaseVariantOutputImpl }.forEach { output ->
|
outputs.map { it as BaseVariantOutputImpl }.forEach { output ->
|
||||||
output.outputFileName = "LSPosedManager-${defaultConfig.versionName}-${defaultConfig.versionCode}-${buildType.name}.apk"
|
output.outputFileName = "LSPosedManager-${verName}-${verCode}-${buildType.name}.apk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val optimizeReleaseResources = task("optimizeReleaseRes").doLast {
|
val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
||||||
val aapt2 = Paths.get(project.android.sdkDirectory.path, "build-tools", project.android.buildToolsVersion, "aapt2")
|
val aapt2 = Paths.get(
|
||||||
val zip = Paths.get(project.buildDir.path, "intermediates", "processed_res", "release", "out", "resources-release.ap_")
|
project.android.sdkDirectory.path,
|
||||||
|
"build-tools",
|
||||||
|
project.android.buildToolsVersion,
|
||||||
|
"aapt2"
|
||||||
|
)
|
||||||
|
val zip = Paths.get(
|
||||||
|
project.buildDir.path,
|
||||||
|
"intermediates",
|
||||||
|
"optimized_processed_res",
|
||||||
|
"release",
|
||||||
|
"resources-release-optimize.ap_"
|
||||||
|
)
|
||||||
val optimized = File("${zip}.opt")
|
val optimized = File("${zip}.opt")
|
||||||
val cmd = exec {
|
val cmd = exec {
|
||||||
commandLine(aapt2, "optimize", "--collapse-resource-names", "-o", optimized, zip)
|
commandLine(
|
||||||
|
aapt2,
|
||||||
|
"optimize",
|
||||||
|
"--collapse-resource-names",
|
||||||
|
"--enable-sparse-encoding",
|
||||||
|
"-o",
|
||||||
|
optimized,
|
||||||
|
zip
|
||||||
|
)
|
||||||
isIgnoreExitValue = false
|
isIgnoreExitValue = false
|
||||||
}
|
}
|
||||||
if (cmd.exitValue == 0) {
|
if (cmd.exitValue == 0) {
|
||||||
|
|
@ -110,8 +130,8 @@ val optimizeReleaseResources = task("optimizeReleaseRes").doLast {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.whenTaskAdded {
|
tasks.whenTaskAdded {
|
||||||
if (name == "shrinkReleaseRes") {
|
if (name == "optimizeReleaseResources") {
|
||||||
finalizedBy(optimizeReleaseResources)
|
finalizedBy(optimizeReleaseRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,12 @@
|
||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
-renamesourcefileattribute
|
|
||||||
-keep class io.github.lsposed.manager.Constants { *; }
|
-keep class io.github.lsposed.manager.Constants { *; }
|
||||||
-keepclasseswithmembers class io.github.lsposed.manager.receivers.LSPosedManagerServiceClient {
|
-keepclasseswithmembers class io.github.lsposed.manager.receivers.LSPosedManagerServiceClient {
|
||||||
private static android.os.IBinder binder;
|
private static android.os.IBinder binder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
public static final ** CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||||
public static void check*(...);
|
public static void check*(...);
|
||||||
public static void throw*(...);
|
public static void throw*(...);
|
||||||
|
|
@ -31,3 +15,6 @@
|
||||||
public static *** v(...);
|
public static *** v(...);
|
||||||
public static *** d(...);
|
public static *** d(...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-repackageclasses
|
||||||
|
-allowaccessmodification
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ android {
|
||||||
}
|
}
|
||||||
named("release") {
|
named("release") {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
proguardFiles("proguard-rules.pro")
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,16 @@
|
||||||
|
|
||||||
-keep class de.robv.android.xposed.** {*;}
|
-keep class de.robv.android.xposed.** {*;}
|
||||||
-keep class android.** { *; }
|
-keep class android.** { *; }
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
public static final ** CREATOR;
|
||||||
|
}
|
||||||
-keepclasseswithmembers class io.github.lsposed.lspd.core.Main {
|
-keepclasseswithmembers class io.github.lsposed.lspd.core.Main {
|
||||||
public static void forkSystemServerPost(android.os.IBinder);
|
public static void forkSystemServerPost(android.os.IBinder);
|
||||||
public static void forkAndSpecializePost(java.lang.String, java.lang.String, android.os.IBinder);
|
public static void forkAndSpecializePost(java.lang.String, java.lang.String, android.os.IBinder);
|
||||||
public static void main(java.lang.String[]);
|
public static void main(java.lang.String[]);
|
||||||
}
|
}
|
||||||
-keepnames class io.github.lsposed.lspd.hooker.HandleBindAppHooker
|
-keepnames class io.github.lsposed.lspd.hooker.HandleBindAppHooker
|
||||||
-keepclasseswithmembers class io.github.lsposed.lspd.nativebridge.* {
|
-keepclasseswithmembers,includedescriptorclasses class * {
|
||||||
native <methods>;
|
native <methods>;
|
||||||
}
|
}
|
||||||
-keepclasseswithmembers class io.github.lsposed.lspd.nativebridge.ClassLinker {
|
-keepclasseswithmembers class io.github.lsposed.lspd.nativebridge.ClassLinker {
|
||||||
|
|
@ -45,3 +48,5 @@
|
||||||
public static *** v(...);
|
public static *** v(...);
|
||||||
public static *** d(...);
|
public static *** d(...);
|
||||||
}
|
}
|
||||||
|
-repackageclasses
|
||||||
|
-allowaccessmodification
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ android {
|
||||||
buildTypes {
|
buildTypes {
|
||||||
named("release") {
|
named("release") {
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
proguardFiles("proguard-rules.pro")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,7 @@
|
||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
-keepclasseswithmembers class io.github.lsposed.lspd.Application { *; }
|
-keepclasseswithmembers class io.github.lsposed.lspd.Application { *; }
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
public static final ** CREATOR;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue