Skip to content

Commit

Permalink
Proguard code trimming, with keep rules for uniffi/jna (#9)
Browse files Browse the repository at this point in the history
* proguard (keep) rules for the win

* add documentation regarding a proguard keep rule syntax

* Add some documentation for keep rule
  • Loading branch information
nain-F49FF806 authored Jul 14, 2024
1 parent 6d99bb0 commit 64aa826
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "alt.nainapps.sharepaste"
minSdk = 26
targetSdk = 34
versionCode = 1720700000
versionName = "2024.07.11"
versionCode = 1720956000
versionName = "2024.07.14"
setProperty("archivesBaseName", "sharepaste.oo")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -49,8 +49,8 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isShrinkResources = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
18 changes: 18 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@
#-renamesourcefileattribute SourceFile

-dontwarn org.gradle.api.Plugin
# https://stackoverflow.com/a/14157641
-keep class uniffi.pbcli.** { *; }
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
# https://stackoverflow.com/a/64553038
-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }
# These auto recommended rules are related to above
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn java.awt.Component
-dontwarn java.awt.GraphicsEnvironment
-dontwarn java.awt.HeadlessException
-dontwarn java.awt.Window

# I don't want to obfuscte code, just trim
-dontobfuscate

0 comments on commit 64aa826

Please sign in to comment.