Skip to content

Commit 69f7390

Browse files
committed
Adjust proguard for Android R8
1. Use JDK 21 2. Update android plugins for JDK 21 3. Update gradle wrapper The new R8 engine will change more class names than before, we thus need to save those needed ones. Currently, due to a bug of Android Application Gradle Plugin 8.4, i.e, com.android.application > com.android.application.gradle.plugin, one can not perform the task optimizeReleaseResources without errors. To see the bug, run `./gradlew --stacktrace --info optimizeZygiskReleaseResources` It shows that the commnd `aapt2` has wrong working directory. Hence, we skip this task.
1 parent f3beb86 commit 69f7390

10 files changed

+44
-30
lines changed

.github/workflows/core.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: actions/setup-java@v3
5757
with:
5858
distribution: "temurin"
59-
java-version: "17"
59+
java-version: "21"
6060

6161
- name: Setup Gradle
6262
uses: gradle/gradle-build-action@v2

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.project
2+
.settings
13
*.iml
24
.gradle
35
/local.properties

build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ val androidTargetSdkVersion by extra(34)
7070
val androidMinSdkVersion by extra(27)
7171
val androidBuildToolsVersion by extra("34.0.0")
7272
val androidCompileSdkVersion by extra(34)
73-
val androidCompileNdkVersion by extra("26.1.10909125")
74-
val androidSourceCompatibility by extra(JavaVersion.VERSION_17)
75-
val androidTargetCompatibility by extra(JavaVersion.VERSION_17)
73+
val androidCompileNdkVersion by extra("26.3.11579264")
74+
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
75+
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)
7676

7777
tasks.register("Delete", Delete::class) {
7878
delete(rootProject.layout.buildDirectory)

core/proguard-rules.pro

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
-keep class android.** { *; }
12
-keep class de.robv.android.xposed.** {*;}
23
-keep class io.github.libxposed.** {*;}
4+
-keep class org.lsposed.lspd.core.* {*;}
5+
-keep class org.lsposed.lspd.impl.LSPosedBridge$NativeHooker {*;}
6+
-keep class org.lsposed.lspd.impl.LSPosedBridge$HookerCallback {*;}
7+
-keep class org.lsposed.lspd.util.Hookers {*;}
8+
39
-keepattributes RuntimeVisibleAnnotations
4-
-keep class android.** { *; }
510
-keepclasseswithmembers,includedescriptorclasses class * {
611
native <methods>;
712
}
@@ -15,15 +20,6 @@
1520
@io.github.libxposed.api.annotations.BeforeInvocation <methods>;
1621
@io.github.libxposed.api.annotations.AfterInvocation <methods>;
1722
}
18-
-keepclassmembers class org.lsposed.lspd.impl.LSPosedBridge$NativeHooker {
19-
<init>(java.lang.reflect.Executable);
20-
callback(...);
21-
}
22-
-keepclassmembers class org.lsposed.lspd.impl.LSPosedBridge$HookerCallback {
23-
final *** beforeInvocation;
24-
final *** afterInvocation;
25-
HookerCallback(...);
26-
}
2723
-assumenosideeffects class android.util.Log {
2824
public static *** v(...);
2925
public static *** d(...);

gradle/libs.versions.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
2-
agp = "8.2.1"
3-
kotlin = "1.9.22"
4-
nav = "2.7.6"
2+
agp = "8.4.0"
3+
kotlin = "1.9.23"
4+
nav = "2.7.7"
55
appcenter = "5.0.4"
66
libxposed = "100"
77
glide = "4.16.0"

gradle/wrapper/gradle-wrapper.jar

-9 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

magisk-loader/build.gradle.kts

+16-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.apache.tools.ant.filters.FixCrLfFilter
2222
import org.apache.tools.ant.filters.ReplaceTokens
2323
import java.io.ByteArrayOutputStream
2424
import java.security.MessageDigest
25+
import com.android.build.gradle.internal.tasks.OptimizeResourcesTask
2526

2627
plugins {
2728
alias(libs.plugins.agp.app)
@@ -200,7 +201,8 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
200201
rename(".*\\.apk", "daemon.apk")
201202
}
202203
into("lib") {
203-
from(layout.buildDirectory.dir("intermediates/stripped_native_libs/$variantCapped/out/lib")) {
204+
val libDir = variantCapped + "/strip${variantCapped}DebugSymbols"
205+
from(layout.buildDirectory.dir("intermediates/stripped_native_libs/$libDir/out/lib")) {
204206
include("**/liblspd.so")
205207
}
206208
}
@@ -303,7 +305,7 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
303305
}
304306
outputStream.toString().trim()
305307
}
306-
workingDir(project(":daemon").layout.buildDirectory.dir("intermediates/stripped_native_libs/debug/out/lib/$abi"))
308+
workingDir(project(":daemon").layout.buildDirectory.dir("intermediates/stripped_native_libs/debug/stripDebugDebugSymbols/out/lib/$abi"))
307309
}
308310
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
309311
}
@@ -343,5 +345,17 @@ task("reRunApp") {
343345
finalizedBy(reRunDaemon)
344346
}
345347

348+
tasks.withType(OptimizeResourcesTask::class.java) {
349+
onlyIf { false }
350+
// doFirst {
351+
// val variantCapped = name.substring(8, name.length - 9)
352+
// val working_dir = layout.buildDirectory.dir("intermediates/optimized_processed_res/$variantCapped").get().getAsFile()
353+
// val subDir = File(working_dir, name)
354+
// if (subDir.isDirectory()) {
355+
// subDir.copyRecursively(working_dir, true)
356+
// }
357+
// }
358+
}
359+
346360
evaluationDependsOn(":app")
347361
evaluationDependsOn(":daemon")

magisk-loader/proguard-rules.pro

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
-repackageclasses
1616
-allowaccessmodification
1717
-dontwarn org.slf4j.impl.StaticLoggerBinder
18+
-dontwarn org.lsposed.lspd.core.*
19+
-dontwarn org.lsposed.lspd.util.Hookers

0 commit comments

Comments
 (0)