Reputation: 2660
AGPBI
gives this as output:
> Task :app:minifyReleaseWithR8
AGPBI: {"kind":"warning","text":"Unexpected reference to missing service class: META-INF/services/reactor.blockhound.integration.BlockHoundIntegration.","sources":[{"file":"/app/build/intermediates/merged_java_res/release/base.jar"}],"tool":"R8"}
AGPBI: {"kind":"warning","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /app/build/outputs/mapping/release/missing_rules.txt.\n","sources":[{}]}
AGPBI: {"kind":"warning","text":"Missing class com.aayushatharva.brotli4j.Brotli4jLoader (referenced from: void io.netty.handler.codec.compression.Brotli.<clinit>() and 2 other contexts)\n
Missing class com.aayushatharva.brotli4j.decoder.DecoderJNI$Status (referenced from: void io.netty.handler.codec.compression.BrotliDecoder$1.<clinit>() and 1 other context)\n
Missing class com.aayushatharva.brotli4j.decoder.DecoderJNI$Wrapper (referenced from: com.aayushatharva.brotli4j.decoder.DecoderJNI$Wrapper io.netty.handler.codec.compression.BrotliDecoder.decoder and 4 other contexts)\n
Missing class com.aayushatharva.brotli4j.encoder.Encoder$Mode (referenced from: void io.netty.handler.codec.compression.BrotliOptions.<clinit>())\n
Missing class com.aayushatharva.brotli4j.encoder.Encoder$Parameters (referenced from: com.aayushatharva.brotli4j.encoder.Encoder$Parameters io.netty.handler.codec.compression.BrotliEncoder.parameters and 7 other contexts)\n
Missing class com.aayushatharva.brotli4j.encoder.Encoder (referenced from: io.netty.buffer.ByteBuf io.netty.handler.codec.compression.BrotliEncoder.allocateBuffer(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, boolean))\n
Missing class com.android.org.conscrypt.SSLParametersImpl (referenced from: void org.conscrypt.KitKatPlatformOpenSSLSocketImplAdapter.<init>(org.conscrypt.AbstractConscryptSocket))\n
Missing class com.github.luben.zstd.Zstd (referenced from: io.netty.buffer.ByteBuf io.netty.handler.codec.compression.ZstdEncoder.allocateBuffer(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, boolean) and 1 other context)\n
Missing class com.google.protobuf.ExtensionRegistry (referenced from: void io.netty.handler.codec.protobuf.ProtobufDecoder.<init>(com.google.protobuf.MessageLite, com.google.protobuf.ExtensionRegistry))\n
Missing class com.google.protobuf.ExtensionRegistryLite (referenced from: com.google.protobuf.ExtensionRegistryLite io.netty.handler.codec.protobuf.ProtobufDecoder.extensionRegistry and 2 other contexts)\n
The missing files seem to be part of the bouncycastle
library. Here is my proguard
file:
-keep class org.spongycastle.** { *; }
-dontwarn org.spongycastle.**
# When I remove this, java.security.cert.CertificateException: X.509 not found is thrown
-keep class org.bouncycastle.** { *; }
-keep interface org.bouncycastle.**
# I got the missing classes from missing_rules.txt and added the package names that created the problem here:
-keep class org.conscrypt.** { *; }
-keep class io.netty.** { *; }
-keep class com.aayushatharva.** { *; }
-keep class ** { *; }
build.gradle (app):
implementation "org.conscrypt:conscrypt-android:$conscrypt"
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.69'
Why does it still gives the error while I add the correct missing package names?
Upvotes: 102
Views: 123759
Reputation: 2610
Do this for flutter:
build\app\outputs\mapping\release\missing_rules.txt
android/app/proguard-rules.pro
With this the build is working fine for me
Upvotes: 15
Reputation: 5288
After long time trouble, fix it by below steps.
Try to create build at machine level and find missing_rules.txt
build >> output >> mapping >> aapstoreliverelease (depend on what environment you selected) >> missing_rules.txt
Copy missiing rules and paste it into progaurd file and try to run.
It'll work.
In my case missing rules are below.
# 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.apache.commons.lang.builder.ToStringBuilder
-dontwarn org.slf4j.impl.StaticLoggerBinder
Note :
hope it will work for you.
Upvotes: 4
Reputation: 125
In my case (Flutter) the issue was: ERROR: R8: Missing class com.google.mlkit.vision.text.chinese.ChineseTextRecognizerOptions$Builder (referenced from: com.google.mlkit.vision.text.TextRecognizer com.google_mlkit_text_recognition.TextRecognizer.initialize(io.flutter.plugin.common.MethodCall))
The issue is fixed! I created the proguard-rules.pro file directly from Android Studio.
NOTE: the name of the file should looks "proguard-rules.pro" not like "proguard-rules.pro.txt" check how it looks in Android Studio.
Inside the ProGuard file, you need to specify which classes should be removed, like this:
-dontwarn com.google.mlkit.vision.text.chinese.** -assumenosideeffects class com.google.mlkit.vision.text.chinese.** { *; }
Upvotes: 1
Reputation: 373
If the missing classes are present in your own Android library, then you can add the following to the libraries proguard.pro
file:
-keep class packagename.classname
or simply
-keep class packagename.*
This will ensure that the minification of the library doesn't drop these classes that are used in the root project.
Upvotes: 3
Reputation: 26
In my case inside of proguard-rules.pro file i add this line ,its solve my problem
-dontwarn com.google.android.play.core.**
you can open android\app\build\outputs\mapping\release\missing_rules.txt this file and then copy all and added all inside of proguard-rules.pro file
Upvotes: 0
Reputation: 9
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in D:\Project Name\build\app\outputs\mapping\release\missing_rules.txt.
ERROR: R8: Missing class com.google.errorprone.annotations.CanIgnoreReturnValue (referenced from: com.google.crypto.tink.KeysetManager com.google.crypto.tink.KeysetManager.add(com.google.crypto.tink.KeyTemplate) and 52 other contexts)
Missing class com.google.errorprone.annotations.CheckReturnValue (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 1 other context)
Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 40 other contexts)
Missing class com.google.errorprone.annotations.RestrictedApi (referenced from: com.google.crypto.tink.aead.AesEaxKey$Builder com.google.crypto.tink.aead.AesEaxKey.builder() and 6 other contexts)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete
I faced the same issue while building apk and on my case
fixed just by adding these two lines in my app/build.gradle
above the line signingConfig = signingConfigs.debug
:
minifyEnabled false
shrinkResources false
Upvotes: 0
Reputation: 51
In my case the error was caused by smart_auth
plugin. I had not added the plugin directly is was a transitive plugin (a plugin used by another plugin that you may have added). I found that pinput was the plugin that required smart_auth
so I updated pinput
to the latest version and then it got build.
Upvotes: 0
Reputation: 293
in this file write some code below-
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.google.firebase.** { *; }
-dontwarn io.flutter.embedding.**
-ignorewarnings
Upvotes: 27
Reputation: 21
Just add the following lines of code in the proguard-rules.pro and again build the signed apk or app bundle. It worked for me at last. find the missing classes accordingly and add '-dontwarn' followed by the class name.
-dontwarn com.android.org.conscrypt.SSLParametersImpl
-dontwarn org.apache.harmony.xnet.provider.jsse.SSLParametersImpl
Upvotes: 2
Reputation: 1
Change minifyEnabled true
to minifyEnabled false
in build.gradle (app)
Upvotes: -20
Reputation: 3378
I upgrade gradle to 8.0
when i package my app I get the same problem.
this is the error message
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in your path to missing_rules.txt
I follow the path to missing_rules.txt like this
app -> build -> outputs -> mapping -> your_app_name -> missing_rules.txt
I get those message
# Please add these rules to your existing keep rules in order to
suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn android.os.ServiceManager*
-dontwarn com.bun.miitmdid.core.MdidSdkHelper*
-dontwarn com.bun.miitmdid.interfaces.IIdentifierListener*
-dontwarn com.bun.miitmdid.interfaces.IdSupplier*
-dontwarn com.google.firebase.iid.FirebaseInstanceId*
-dontwarn com.google.firebase.iid.InstanceIdResult*
-dontwarn com.huawei.hms.ads.identifier.AdvertisingIdClient$Info*
-dontwarn com.huawei.hms.ads.identifier.AdvertisingIdClient*
-dontwarn com.tencent.android.tpush.otherpush.OtherPushClient*
I copy those messages into proguard-rules.pro
then i fix this problem.
Upvotes: 217
Reputation: 295
instead of suppressing it , you should find the missing class. for example if getting error related to annotations, please add following dependency to your app level build.gradle
//https://mvnrepository.com/artifact/com.google.errorprone/error_prone_annotations
implementation 'com.google.errorprone:error_prone_annotations:2.23.0'
this will add the missing class to your project and will remove error.
Upvotes: 5
Reputation: 37
Copy the missing rules from the file android\app\build\outputs\mapping\release\missing_rules.txt
and paste it in the android\app\proguard-rules.pro
Upvotes: 1
Reputation: 123
Write the -dontwarn
rules in the missing_rules.txt file into the proguard-rules file.
Upvotes: 6
Reputation: 61
Just add -ignorewarnings
to proguard-rules.pro as described in the Android 8 release notes.
Upvotes: 6
Reputation: 167
You can disable minifyEnabled when debug the app since you are debugging the app on your phone but for the release version let minifyEnabled true ;
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.ProfileForsign
}
debug {
signingConfig signingConfigs.ProfileForsign
debuggable true
minifyEnabled false
}
}
Upvotes: -5
Reputation: 1514
Not directly OP's issue, but if you find R8 failing your builds about missing rules and you're using an older version of OkHttp, you can upgrade OkHttp to 4.11.0 for the necessary Proguard rules instead of adding them to your project.
Upvotes: 17
Reputation: 61
-dontwarn android.media.Spatializer$OnSpatializerStateChangedListener
-dontwarn android.media.Spatializer
Upvotes: 0
Reputation: 336
These rules worked for me
-dontwarn com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite**
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
Upvotes: 1
Reputation: 4021
Write the -dontwarn rules in the proguard-rules file
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
Upvotes: 1
Reputation: 4628
The missing classes warning tells that the mentioned classes are not present in the input (your source and dependencies) or in the referenced library (Android runtime library android.jar
provided form the Platfrom SDK in this case). When R8 traces the program it will try to handle all the classes, methods and fields that it finds in the part of the program it considers live. Keeping all classes in a package will not change that. There are two options in this case:
-dontwarn
as the class is expected to be missing.For the warning on the class com.android.org.conscrypt.SSLParametersImpl
adding a
-dontwarn com.android.org.conscrypt.SSLParametersImpl`
is the right thing to do, as looking at the source shows that the class extends a class which will be in the KitKat runtime, but not in the app (and also not in android.jar
).
For the remaining warnings a similar decision has to be made.
Upvotes: 28