Skip to content

Commit

Permalink
Add more proguard rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lumpidu committed Feb 6, 2024
1 parent 4df5d1e commit 00bc099
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ android {
shrinkResources true

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro', 'okio.pro', 'retrofit2.pro', 'gson.pro'
'proguard-rules.pro', 'okio.pro', 'retrofit2.pro', 'gson.pro', 'okhttp3.pro'
ndk {
debugSymbolLevel 'full'
}
Expand Down
14 changes: 14 additions & 0 deletions app/okhttp3.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
22 changes: 13 additions & 9 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@
#-renamesourcefileattribute SourceFile

-keep class com.grammatek.simaromur.device.Native* { *; }
-keep class com.grammatek.simaromur.device.flite.Native* { *; }

-keep class opennlp.** { *; }
-dontwarn opennlp.**

-keep class org.pytorch.** { *; }
-keep class com.facebook.** { *; }
-keep class org.kohsuke.github** { *; }
-keep class ai.onnxruntime.** { *; }
-keep class io.jsonwebtoken.** { *; }
-keep class okhttp3.** { *; }
-keep class javax.naming.NamingException.** { *; }
-keep class javax.naming.directory.Attributes.** { *; }
-keep class androidx.appcompat.view.ContextThemeWrapper.** { *; }
-keep class com.oracle.svm.core.annotate.Delete.** { *; }
-keep class com.oracle.svm.core.annotate.Substitute.** { *; }
-keep class com.oracle.svm.core.annotate.TargetClass.** { *; }
-keep class com.oracle.svm.core.configure.ResourcesRegistry.** { *; }
-keep class io.jsonwebtoken.JwtBuilder.** { *; }
-keep class io.jsonwebtoken.Jwts.** { *; }
-keep class io.jsonwebtoken.SignatureAlgorithm.** { *; }
-keep class okhttp3.OkUrlFactory.** { *; }
-keep class org.kohsuke.github** { *; }

# warnings generated via kohsuke github api
-dontwarn com.infradna.tool.bridge_method_injector.BridgeMethodsAdded
Expand All @@ -45,8 +50,7 @@
-dontwarn java.beans.ConstructorProperties
-dontwarn java.beans.Transient

# warnings generated via okhttp3 internal platform, these seem not to be needed on Android
-dontwarn okhttp3.internal.platform.*
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.conscrypt.Conscrypt
-dontwarn io.jsonwebtoken.JwtBuilder
-dontwarn io.jsonwebtoken.Jwts
-dontwarn io.jsonwebtoken.SignatureAlgorithm
-dontwarn okhttp3.OkUrlFactory
12 changes: 10 additions & 2 deletions app/retrofit2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

# Keep generic signature of Call (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
# Keep inherited services.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface * extends <1>

# 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

# R8 full mode strips generic signatures from return types if not kept.
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response

0 comments on commit 00bc099

Please sign in to comment.