When I generate my APK with the following proguard rules
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-keep public class com.google.firebase.* {public *;}
-dontwarn com.google.firebase.**
I get this error
Unexpected error while performing partial evaluation: Class =
[com/google/firebase/remoteconfig/FirebaseRemoteConfig] Method
= [getInstance()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;]
Exception = [java.lang.IllegalArgumentException] (Can't find common
super class of [com/google/android/gms/internal/zzama] (with 2 known
super classes) and [com/google/android/gms/internal/zzamb$zzc] (with 1
known super classes))
Warning: Exception while processing task java.io.IOException:
java.lang.IllegalArgumentException: Can't find common super class of
[com/google/android/gms/internal/zzama] (with 2 known super classes)
and [com/google/android/gms/internal/zzamb$zzc] (with 1 known super
classes)
I found this URL http://proguard.sourceforge.net/manual/troubleshooting.html#superclass which says me to add the missing class. I am not sure which is the missing class here. Any inputs would be really appreciated.
I found the issue. it was because I had not updated the version of firebase once i updated google pay services in my gradle. Make sure that the version of your play service sdk and firebase sdk is same
Related
Recently went through and updated most libraries in our app, which of course has led to ProGuard fun. We've gotten it down to just 3 warnings, which I can't for the life of me figure out what to do about.
Here's the warnings:
Warning: kotlinx.coroutines.AbstractContinuation: can't find referenced method 'kotlin.coroutines.CoroutineContext getContext()' in program class kotlinx.coroutines.AbstractContinuation
Warning: kotlinx.coroutines.DelayKt: can't find referenced method 'kotlin.coroutines.CoroutineContext getContext()' in program class kotlinx.coroutines.CancellableContinuation
Warning: kotlinx.coroutines.channels.TickerChannelsKt: can't find referenced method 'kotlin.coroutines.CoroutineContext plus(kotlin.coroutines.CoroutineContext)' in program class kotlinx.coroutines.CoroutineDispatcher
We're using the recommended set of kotlinx.coroutines ProGuard rules:
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler{}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
I've tried various combinations of aggressively keeping or ignoring those classes, but I'll be the first person to tell you that I'm not remotely a ProGuard expert and don't really know what I'm doing.
In general, any over aggressive usage of -dontwarn or -ignorewarnings seems to result in this error message:
Unexpected error while performing partial evaluation:
Class = [kotlinx/coroutines/CommonPool]
Method = [<clinit>()V]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/Integer] (with 3 known super classes) and [kotlinx/coroutines/CommonPool] (with 3 known super classes))
Unexpected error while preverifying:
Class = [kotlinx/coroutines/CommonPool]
Method = [<clinit>()V]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/Integer] (with 3 known super classes) and [kotlinx/coroutines/CommonPool] (with 3 known super classes))
And any more subtle/targeted methods (i.e. keeping the specific classes that get called back, trying to keep methods, etc) result in no change in the 3 warnings I pasted above.
Facing notorious java.lang.VerifyError. Initially problem showed up in Fabric. Was able to reproduce (with identical stacktrace) once set minifyEnabled true for debug build.
Caused by java.lang.VerifyError: Verifier rejected class com.evernote.client.conn.mobile.TEvernoteHttpClient: void com.evernote.client.conn.mobile.TEvernoteHttpClient.cancel() failed to verify: void com.evernote.client.conn.mobile.TEvernoteHttpClient.cancel(): [0x6] 'this' argument 'Reference: org.apache.http.client.methods.HttpRequestBase' not instance of 'Reference: org.apache.http.client.methods.AbstractExecutionAwareRequest'
void com.evernote.client.conn.mobile.TEvernoteHttpClient.flush() failed to verify: void com.evernote.client.conn.mobile.TEvernoteHttpClient.flush(): [0x7F] 'this' argument 'Reference: org.apache.http.impl.client.DefaultHttpClient' not instance of 'Reference: org.apache.http.impl.client.CloseableHttpClient' (declaration of 'com.evernote.client.conn.mobile.TEvernoteHttpClient' appears in base.apk)
at com.evernote.client.android.ClientFactory.createNoteStoreClient + 85(ClientFactory.java:85)
I see that typically java.lang.VerifyError issues are recognized as related to difference between code to compile and run against.
This is not the case since code runs just fine when minification is disabled.
The way I see this can be helped is making another rule, but I am failing to understand which classes need to be kept from this error details.
We are already doing
-keep class com.evernote.** { *; }
-keep interface com.evernote.** { *; }
-keep class org.apache.http.** { *; }
-keep interface org.apache.http.** { *; }
... and those classes don't get modified in any way. I've checked it using -printusage ./full-r8-config.txt instruction and checking the output. Classes mentioned in error details do not show up there.
UPDATE 1 day later:
Really strange thing going on here.
So far I have a verified backup plan: switching back to proguard fixes issue.
But in case if I want to stay with R8, here comes:
using -dontshrink, -dontoptimize and -dontobfuscate (all three at once) does no impact;
forcing specific apache.http version dependency does no impact;
I've checked mapping: neither Evernore SDK, nor Apache http classes don't get obfuscated;
issue pertains when app executed on api22 device (emulator, actually);
I was able to debug code once I had -dontobfuscate set. All goes well until Evernote's ClientFactory#createUserStoreClient decides to instantiate TEvernoteHttpClient - the moment program execution touches latter class's constructor - exception thrown.
It looks like it is all good to go, but this verifier fails.
Later update:
Issue filed as a bug for R8: https://issuetracker.google.com/issues/139268389. Please feel free to star it if facing similar situation (all code is in place but VerifyError is thrown)
Try to write below proguard rules.
-dontwarn com.evernote.client.conn.mobile.TAndroidTransport
-dontwarn com.evernote.client.conn.mobile.DiskBackedByteStore
-dontwarn com.evernote.client.conn.mobile.ByteStore
-dontwarn org.apache.commons.codec.binary.Base64
Error while generating signed APK.
Exception while processing task java.io.IOException:
java.lang.IllegalArgumentException: Can't find common super class of
[com/google/android/gms/internal/zzmk] (with 1 known super classes)
and [java/lang/String] (with 2 known super classes)
Although,I have added the below lines in the "proguard-rules.pro" file yet I am getting the same error.
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
Edit:
Now I am able to generate signed APK after adding
-dontoptimize
-dontpreverify
in the proguard-rules.pro .
Please let me know if it is okay to use dontoptimize.
Is there any other way?
While building project using ANT 1.8.2 and proguarg 4.8.1
[proguard] Unexpected error while evaluating instruction:
[proguard] Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl]
[proguard] Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;]
[proguard] Instruction = [18] areturn
[proguard] Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate]))
[proguard] Unexpected error while performing partial evaluation:
[proguard] Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl]
[proguard] Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;]
[proguard] Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate]))
BUILD FAILED
E:\adt-bundle-windows\sdk\tools\ant\build.xml:864: java.lang.IllegalArgumentException: Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate])
android-support-v4.jar is in class path and project dependecies...
From Eclipse all but debug version is built OK.
Ant display those errors...
How do avoid this? I understand if Eclipse builds this OK, the Ant have to build too..
P.S. My project is android-10 target and I don't want and can't make it target-16 if somebody'll advise...
what about try to add these to your proguard.cf?
-libraryjars libs/android-support-v4.jar
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment
You should specify a target SDK in your project.properties that in this case contains 'android.view.View$AccessibilityDelegate' (SDK level 14 or higher). ProGuard's shrinking/optimization/obfuscation need at least the same base SDK that was used for compiling the application and its libraries. The support library was compiled against this more recent SDK, so ProGuard needs it as well.
You can still specify a different target/min/max SDK in your AndroidManifest.xml, for running the application. You should of course make sure that the application is indeed compatible with those specified SDKs.
I'm trying to set up a basic ProGuard with Amazon IAP integrated. However when I'm trying to export my APK, I got the following errors:
[2012-06-17 10:59:44 - sc] Proguard returned with error code 1. See console
[2012-06-17 10:59:44 - sc] Unexpected error while performing partial evaluation:
[2012-06-17 10:59:44 - sc] Class = [com/amazon/inapp/purchasing/KiwiResponseHandler$PurchaseResponseHandlerRunnable]
[2012-06-17 10:59:44 - sc] Method = [run()V]
[2012-06-17 10:59:44 - sc] Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/String] (with 4 known super classes) and [com/amazon/inapp/purchasing/KiwiPurchaseResponseCommandTask] (with 1 known super classes))
[2012-06-17 10:59:44 - sc] java.lang.IllegalArgumentException: Can't find common super class of [java/lang/String] (with 4 known super classes) and [com/amazon/inapp/purchasing/KiwiPurchaseResponseCommandTask] (with 1 known super classes)
[2012-06-17 10:59:44 - sc] at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:344)
[2012-06-17 10:59:44 - sc] at proguard.evaluation.value.IdentifiedReferenceValue.generalize(IdentifiedReferenceValue.java:65)
[2012-06-17 10:59:44 - sc] at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:481)
...
I have the default ProGuard configuration file, and I have already added the:
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
lines to it. What went wrong?
There is some fishy stuff with the recommended config of Amazon.
1) -dontwarn is hiding a deeper underlying issue, where some Amazon specific libraries are not present, but referenced so that proguard will try some wired optimization which likely causes the above mentioned stacktrace.
2) -dontoptimize is disabling all optimizations, which is defenitivly wrong, because it is most probably just one specific optimization which is causing this issue, and proguards optimizations are removing alot of dead and unused code from your app and its libraries, so it shrinks the total dex size.
I guess fixing 1) is the real solution. This could be eventually achieved by extracting Amazons system libs from a device and make them present (as a provided lib) while building
the app.
For 2) you can try:
-dontwarn com.amazon.**
-keep class com.amazon.** {
*;
}
-optimizations !code/allocation/variable
which solved the issue for me.
Per Amazon's SDK Docs, here are the lines you should include:
Preventing Obfuscation of In-App Purchasing API
When incorporating the In-App Purchasing API into your library, you will need to specify classes to 'keep' and not obfuscate. Add the following lines anywhere in your proguard.cfg file.
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
In addition, you will also need to skip Proguard's optimization step.
-dontoptimize
Note: Make sure to remove any other flags dealing with optimization, or any flag that may conflict with the above settings.
In addition, you will also need to lower the number of optimization passes to 1, or skip proguard's optimization step.
-optimizationpasses 1
or
-dontoptimize