Skip to content

Commit

Permalink
Adjust proguard for Android R8
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JingMatrix committed May 18, 2024
1 parent f3beb86 commit 0a93541
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
java-version: "21"

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.project
.settings
*.iml
.gradle
/local.properties
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ val androidTargetSdkVersion by extra(34)
val androidMinSdkVersion by extra(27)
val androidBuildToolsVersion by extra("34.0.0")
val androidCompileSdkVersion by extra(34)
val androidCompileNdkVersion by extra("26.1.10909125")
val androidSourceCompatibility by extra(JavaVersion.VERSION_17)
val androidTargetCompatibility by extra(JavaVersion.VERSION_17)
val androidCompileNdkVersion by extra("26.3.11579264")
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)

tasks.register("Delete", Delete::class) {
delete(rootProject.layout.buildDirectory)
Expand Down
16 changes: 6 additions & 10 deletions core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
-keep class android.** { *; }
-keep class de.robv.android.xposed.** {*;}
-keep class io.github.libxposed.** {*;}
-keep class org.lsposed.lspd.core.* {*;}
-keep class org.lsposed.lspd.impl.LSPosedBridge$NativeHooker {*;}
-keep class org.lsposed.lspd.impl.LSPosedBridge$HookerCallback {*;}
-keep class org.lsposed.lspd.util.Hookers {*;}

-keepattributes RuntimeVisibleAnnotations
-keep class android.** { *; }
-keepclasseswithmembers,includedescriptorclasses class * {
native <methods>;
}
Expand All @@ -15,15 +20,6 @@
@io.github.libxposed.api.annotations.BeforeInvocation <methods>;
@io.github.libxposed.api.annotations.AfterInvocation <methods>;
}
-keepclassmembers class org.lsposed.lspd.impl.LSPosedBridge$NativeHooker {
<init>(java.lang.reflect.Executable);
callback(...);
}
-keepclassmembers class org.lsposed.lspd.impl.LSPosedBridge$HookerCallback {
final *** beforeInvocation;
final *** afterInvocation;
HookerCallback(...);
}
-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.experimental.enableNewResourceShrinker.preciseShrinking=true
android.enableAppCompileTimeRClass=true
android.useAndroidX=true
android.nonFinalResIds=false
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
agp = "8.2.1"
kotlin = "1.9.22"
nav = "2.7.6"
agp = "8.4.0"
kotlin = "1.9.23"
nav = "2.7.7"
appcenter = "5.0.4"
libxposed = "100"
glide = "4.16.0"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

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

goto fail

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

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
5 changes: 3 additions & 2 deletions magisk-loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
rename(".*\\.apk", "daemon.apk")
}
into("lib") {
from(layout.buildDirectory.dir("intermediates/stripped_native_libs/$variantCapped/out/lib")) {
val libDir = variantCapped + "/strip${variantCapped}DebugSymbols"
from(layout.buildDirectory.dir("intermediates/stripped_native_libs/$libDir/out/lib")) {
include("**/liblspd.so")
}
}
Expand Down Expand Up @@ -303,7 +304,7 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
}
outputStream.toString().trim()
}
workingDir(project(":daemon").layout.buildDirectory.dir("intermediates/stripped_native_libs/debug/out/lib/$abi"))
workingDir(project(":daemon").layout.buildDirectory.dir("intermediates/stripped_native_libs/debug/stripDebugDebugSymbols/out/lib/$abi"))
}
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
}
Expand Down
2 changes: 2 additions & 0 deletions magisk-loader/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
-repackageclasses
-allowaccessmodification
-dontwarn org.slf4j.impl.StaticLoggerBinder
-dontwarn org.lsposed.lspd.core.*
-dontwarn org.lsposed.lspd.util.Hookers

0 comments on commit 0a93541

Please sign in to comment.