I created a flutter plugin that uses in its android implementation:
implementation 'com.microsoft.signalr:signalr:8.0.4'
implementation 'org.slf4j:slf4j-api:2.0.13'
implementation 'org.slf4j:slf4j-jdk14:2.0.13'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.2.0'
}
I hosted it on github and depended on it in my pubspec.yaml in a flutter app.
When I run the app in debug mode it runs normally and the plugin works as expected.
If I try to run it in release mode, the code does not even compile, giving me alot of errors about missing classes:
[ ] ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/haidarmehsen/Work/acksession/flutter/vsa-tablet/build/app/outputs/mapping/release/missing_rules.txt.
[ ] ERROR: R8: Missing class org.bouncycastle.jsse.BCSSLParameters (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
[ ] Missing class org.bouncycastle.jsse.BCSSLSocket (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 5 other contexts)
[ ] Missing class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.<init>())
[ ] Missing class org.conscrypt.Conscrypt$Version (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int))
[ ] Missing class org.conscrypt.Conscrypt (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int) and 4 other contexts)
[ ] Missing class org.conscrypt.ConscryptHostnameVerifier (referenced from: okhttp3.internal.platform.ConscryptPlatform$DisabledHostnameVerifier)
[ ] Missing class org.openjsse.javax.net.ssl.SSLParameters (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List))
[ ] Missing class org.openjsse.javax.net.ssl.SSLSocket (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
[ ] Missing class org.openjsse.net.ssl.OpenJSSE (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.<init>())
[ ] FAILURE: Build failed with an exception.
if I go to the missing rules file indicated in the error log, I find this file:
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
Now we come to what I tried:
- First obviously the error’s suggestion => result: the app compiles, but since I only suppressed the warnings, the plugin code throws errors at runtime.
- Tried defining a proguargd file, referencing it in build.gradle, and using the -keep to keep the classes, also used wildcard patterns to keep everything, but did not work, same error kept happening:
-keep class org.bouncycastle.jsse.BCSSLParameters { *; }
-keep class org.bouncycastle.jsse.BCSSLSocket { *; }
-keep class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider { *; }
-keep class org.conscrypt.Conscrypt$Version { *; }
-keep class org.conscrypt.Conscrypt { *; }
-keep class org.conscrypt.ConscryptHostnameVerifier { *; }
-keep class org.openjsse.javax.net.ssl.SSLParameters { *; }
-keep class org.openjsse.javax.net.ssl.SSLSocket { *; }
-keep class org.openjsse.net.ssl.OpenJSSE { *; }
- Finally used the last resort which is, in my app (not the plugin), I disabled the R8 completely by using
release { signingConfig signingConfigs.release minifyEnabled false shrinkResources false }
this works but is not recommended and it also doubles my app size.
Can you help me solve this error without disabling shrinking of everything?