Răsfoiți Sursa

android: Enable code minification

Charles Lombardo 3 ani în urmă
părinte
comite
d57ae50f17

+ 6 - 1
src/android/app/build.gradle.kts

@@ -78,6 +78,12 @@ android {
         // Signed by release key, allowing for upload to Play Store.
         release {
             signingConfig = signingConfigs.getByName("debug")
+            isMinifyEnabled = true
+            isDebuggable = false
+            proguardFiles(
+                getDefaultProguardFile("proguard-android.txt"),
+                "proguard-rules.pro"
+            )
         }
 
         // builds a release build that doesn't need signing
@@ -86,7 +92,6 @@ android {
             initWith(getByName("release"))
             versionNameSuffix = "-debug"
             signingConfig = signingConfigs.getByName("debug")
-            isMinifyEnabled = false
             enableAndroidTestCoverage = false
             isDebuggable = true
             isJniDebuggable = true

+ 2 - 21
src/android/app/proguard-rules.pro

@@ -1,21 +1,2 @@
-# 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 SourceFile
+# To get usable stack traces
+-dontobfuscate

+ 4 - 0
src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt

@@ -11,6 +11,7 @@ import android.text.method.LinkMovementMethod
 import android.view.Surface
 import android.view.View
 import android.widget.TextView
+import androidx.annotation.Keep
 import androidx.fragment.app.DialogFragment
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
 import org.yuzu.yuzu_emu.YuzuApplication.Companion.appContext
@@ -53,6 +54,7 @@ object NativeLibrary {
         }
     }
 
+    @Keep
     @JvmStatic
     fun openContentUri(path: String?, openmode: String?): Int {
         return if (isNativePath(path!!)) {
@@ -60,6 +62,7 @@ object NativeLibrary {
         } else openContentUri(appContext, path, openmode)
     }
 
+    @Keep
     @JvmStatic
     fun getSize(path: String?): Long {
         return if (isNativePath(path!!)) {
@@ -340,6 +343,7 @@ object NativeLibrary {
         return coreErrorAlertResult
     }
 
+    @Keep
     @JvmStatic
     fun exitEmulationActivity(resultCode: Int) {
         val Success = 0

+ 4 - 0
src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt

@@ -10,12 +10,14 @@ import android.view.KeyEvent
 import android.view.View
 import android.view.WindowInsets
 import android.view.inputmethod.InputMethodManager
+import androidx.annotation.Keep
 import androidx.core.view.ViewCompat
 import org.yuzu.yuzu_emu.NativeLibrary
 import org.yuzu.yuzu_emu.R
 import org.yuzu.yuzu_emu.applets.keyboard.ui.KeyboardDialogFragment
 import java.io.Serializable
 
+@Keep
 object SoftwareKeyboard {
     lateinit var data: KeyboardData
     val dataLock = Object()
@@ -91,6 +93,7 @@ object SoftwareKeyboard {
         Cancel
     }
 
+    @Keep
     data class KeyboardConfig(
         var ok_text: String? = null,
         var header_text: String? = null,
@@ -113,5 +116,6 @@ object SoftwareKeyboard {
     ) : Serializable
 
     // Corresponds to Frontend::KeyboardData
+    @Keep
     data class KeyboardData(var result: Int, var text: String)
 }

+ 2 - 0
src/android/app/src/main/java/org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress.kt

@@ -3,10 +3,12 @@
 
 package org.yuzu.yuzu_emu.disk_shader_cache
 
+import androidx.annotation.Keep
 import org.yuzu.yuzu_emu.NativeLibrary
 import org.yuzu.yuzu_emu.R
 import org.yuzu.yuzu_emu.disk_shader_cache.ui.ShaderProgressDialogFragment
 
+@Keep
 object DiskShaderCacheProgress {
     val finishLock = Object()
     private lateinit var fragment: ShaderProgressDialogFragment