diff --git a/app/apk/build.gradle.kts b/app/apk/build.gradle.kts index 280428f58..ca1414288 100644 --- a/app/apk/build.gradle.kts +++ b/app/apk/build.gradle.kts @@ -1,6 +1,3 @@ -import com.android.build.api.instrumentation.FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS -import com.android.build.api.instrumentation.InstrumentationScope - plugins { id("com.android.application") kotlin("android") @@ -9,7 +6,7 @@ plugins { id("androidx.navigation.safeargs.kotlin") } -setupAppCommon() +setupMainApk() kapt { correctErrorTypes = true @@ -21,27 +18,6 @@ kapt { } android { - namespace = "com.topjohnwu.magisk" - - defaultConfig { - applicationId = "com.topjohnwu.magisk" - vectorDrawables.useSupportLibrary = true - versionName = Config.version - versionCode = Config.versionCode - ndk { - abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") - debugSymbolLevel = "FULL" - } - } - - buildTypes { - release { - isMinifyEnabled = true - isShrinkResources = true - proguardFiles("proguard-rules.pro") - } - } - buildFeatures { dataBinding = true } @@ -49,14 +25,6 @@ android { compileOptions { isCoreLibraryDesugaringEnabled = true } - - androidComponents { - onVariants { - it.instrumentation.setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS) - it.instrumentation.transformClassesWith( - DesugarClassVisitorFactory::class.java, InstrumentationScope.ALL) {} - } - } } dependencies { diff --git a/app/core/build.gradle.kts b/app/core/build.gradle.kts index bfb4ab2e2..8d9c3d5f5 100644 --- a/app/core/build.gradle.kts +++ b/app/core/build.gradle.kts @@ -19,6 +19,7 @@ android { buildConfigField("int", "APP_VERSION_CODE", "${Config.versionCode}") buildConfigField("String", "APP_VERSION_NAME", "\"${Config.version}\"") buildConfigField("int", "STUB_VERSION", Config.stubVersion) + consumerProguardFile("proguard-rules.pro") } buildFeatures { diff --git a/app/apk/proguard-rules.pro b/app/core/proguard-rules.pro similarity index 80% rename from app/apk/proguard-rules.pro rename to app/core/proguard-rules.pro index ac99cce4d..357e009be 100644 --- a/app/apk/proguard-rules.pro +++ b/app/core/proguard-rules.pro @@ -22,28 +22,17 @@ int mActivityHandlesConfigFlags; } -# main --keep,allowoptimization public class com.topjohnwu.magisk.signing.SignBoot { - public static void main(java.lang.String[]); -} - # Strip Timber verbose and debug logging -assumenosideeffects class timber.log.Timber$Tree { public void v(**); public void d(**); } -# https://github.com/square/retrofit/issues/3751#issuecomment-1192043644 -# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). --keep,allowobfuscation,allowshrinking interface retrofit2.Call --keep,allowobfuscation,allowshrinking class retrofit2.Response - # With R8 full mode generic signatures are stripped for classes that are not # kept. Suspend functions are wrapped in continuations where the type argument # is used. -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation - # Excessive obfuscation -repackageclasses 'a' -allowaccessmodification diff --git a/app/stub/build.gradle.kts b/app/stub/build.gradle.kts index 39629167f..eb2654995 100644 --- a/app/stub/build.gradle.kts +++ b/app/stub/build.gradle.kts @@ -27,8 +27,6 @@ android { buildTypes { release { - isMinifyEnabled = true - isShrinkResources = false proguardFiles("proguard-rules.pro") } } @@ -38,7 +36,7 @@ android { } } -setupStub() +setupStubApk() dependencies { implementation(project(":app:shared")) diff --git a/buildSrc/src/main/java/Setup.kt b/buildSrc/src/main/java/Setup.kt index 1bb1b9061..0c5e5f195 100644 --- a/buildSrc/src/main/java/Setup.kt +++ b/buildSrc/src/main/java/Setup.kt @@ -1,6 +1,8 @@ import com.android.build.api.artifact.ArtifactTransformationRequest import com.android.build.api.artifact.SingleArtifact import com.android.build.api.dsl.ApkSigningConfig +import com.android.build.api.instrumentation.FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS +import com.android.build.api.instrumentation.InstrumentationScope import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension @@ -15,6 +17,8 @@ import org.gradle.api.Action import org.gradle.api.DefaultTask import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.Property import org.gradle.api.tasks.Copy @@ -27,6 +31,7 @@ import org.gradle.api.tasks.StopExecutionException import org.gradle.api.tasks.Sync import org.gradle.api.tasks.TaskAction import org.gradle.kotlin.dsl.assign +import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.exclude import org.gradle.kotlin.dsl.filter import org.gradle.kotlin.dsl.get @@ -310,6 +315,10 @@ fun Project.setupAppCommon() { else signingConfigs["debug"] } } + release { + isMinifyEnabled = true + isShrinkResources = true + } } lint { @@ -348,7 +357,34 @@ fun Project.setupAppCommon() { } } -fun Project.setupStub() { +fun Project.setupMainApk() { + setupAppCommon() + + android { + namespace = "com.topjohnwu.magisk" + + defaultConfig { + applicationId = "com.topjohnwu.magisk" + vectorDrawables.useSupportLibrary = true + versionName = Config.version + versionCode = Config.versionCode + ndk { + abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") + debugSymbolLevel = "FULL" + } + } + + androidComponents.onVariants { variant -> + variant.instrumentation.apply { + setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS) + transformClassesWith( + DesugarClassVisitorFactory::class.java, InstrumentationScope.ALL) {} + } + } + } +} + +fun Project.setupStubApk() { setupAppCommon() androidComponents.onVariants { variant ->