Ant + Proguard provide android-support-v4.jar errors - android

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.

Related

D8: Type `sun.misc.Unsafe` was not found

After enabling D8 in my android project, I've started seeing these warnings:
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.<clinit>()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.cache.Striped64.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.hash.LittleEndianByteArray$UnsafeByteArray.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.<clinit>()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.cache.Striped64.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.hash.LittleEndianByteArray$UnsafeByteArray.getUnsafe()`
.
Project builds successfully but at runtime, I see these error logs and due to this, app functionality is affected.
java.lang.AbstractMethodError: abstract method "java.lang.Object com.google.common.base.e.a(java.lang.Object)"
at com.google.common.e.a.i$c.a(SourceFile:1464)
at com.google.common.e.a.i$c.a(SourceFile:1453)
at com.google.common.e.a.i$a.run(SourceFile:1408)
at com.google.common.e.a.l$a.execute(SourceFile:456)
at com.google.common.e.a.i$f.a(SourceFile:153)
at com.google.common.e.a.i.a(SourceFile:1234)
I haven't been able to find anything useful on this after searching for a while. Please help.
And yes, I don't face this error at runtime if D8 is disabled and everything else remains same.
you need to keep sun.misc.Unsafe:
-keep class sun.misc.Unsafe { *; }
-dontnote sun.misc.Unsafe
alternatively, a rule with includedescriptorclasses should keep it dynamically:
-keep,includedescriptorclasses class com.google.common.**
in general:
adding switch -verbose is quite helpful for writing ProGuard configuration rules.
adding switch -dontoptimize can be used to disable all optimization, for a test.
just found this:
R8 now understands proguard specs in META-INF/proguard.
but unless this had been added, one has to add custom rules - instead of using consumer rules.
In your project-proguard file. Please add this:
-keepnames class com.google.common.**
-keep class com.google.common.**
-dontwarn com.google.common.**
It seems to be a sort of bug. But sometimes when you using D8 it tend to renames class names or delete them altogether.

Proguard error when using FirebaseRemoteConfig and Play Services SDK

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

Java.exe exited with code 1. Xamarin

Trying to make archive for publishing and has this error
Java heap size is set to 1G.PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
PROGUARD : warning : there were 148 unresolved references to classes or interfaces.
PROGUARD : warning : there were 2 unresolved references to program class members.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1833,3): error MSB6006: "java.exe" exited with code 1.
I made archive for publishing at Friday and everything was ok. Yesterday I have updates and installed them, but this didn't solve the problem
What's wrong?
Problem is solved
create file named proguard.cfg inside Android project in the solution. Right click and set Build Action to ProguardConfig.
I add this to proguard file
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
Make sure you save file as UTF-8 and NOT UTF-8 BOM

Can't enable Proguard on Android project containing jsch lib

I am trying to use Proguard to obfuscate my Android app which makes use of the library jsch-1.50.jar for uploading files to an SFTP server.
When I do an export from Eclipse, I get warnings "can't reference class" and nothing is produced. I have tried all manner of options to tell Proguard to ignore the jsch classes, but it's not making any difference and therefore I wonder if I am misunderstanding how this works. I am not too worried about the optimisation, but I would like the code obfuscated.
I have setup the proguard-properties as follows:
-keep class com.jcraft.jsch.jce.*
-keep class * extends com.jcraft.jsch.KeyExchange
-keep class com.jcraft.jsch.**
-keep class com.jcraft.jzlib.ZStream
-keep class com.jcraft.jsch.Compression
-keep class org.ietf.jgss.*
-libraryjars /libs/jsch-0.1.50.jar
The project-properties file contains an entry for "proguard.config=proguard-project.txt".
The output from the export with duplicates removed:-
Warning: com.jcraft.jsch.jcraft.Compression: can't find referenced class com.jcraft.jzlib.ZStream
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.Oid
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSManager
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSException
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSContext
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.MessageProp
Warning: there were 44 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Error: Please correct the above warnings first.
Would very much appreciate any pointers.
Thanks
Mike
After a bit more investigation, I found the following...
I had forgotten to include jzlib-1.1.1.jar in the project with the corresponding
-libraryjars /libs/jzlib-1.1.1.jar
entry in the proguard-properties.txt.
Also to ignore the warning regards references to "class org.ietf.jgss", I tried the suggested method of excluding the referencing class
-libraryjars /libs/jsch-0.1.50.jar(!com.jcraft.jsch.jgss/GSSContextKrb5.class)
but that didn't help. In the end, I went with :-
-dontwarn org.ietf.jgss.**

Proguard isn't working with Chartboost?

I'm getting proguard error when trying to compile project with Chartboost Android SDK:
[proguard] Unexpected error while editing code:
[proguard] Class = [com/chartboost/sdk/Libraries/d]
[proguard] Method = [b(Landroid/content/Context;)Lcom/chartboost/sdk/Libraries/CBOrientation;]
[proguard] Exception = [java.lang.IllegalArgumentException] (Invalid instruction offset [65674] in code with length [236])
I added those lines to proguard.cfg but this didn't help:
-libraryjars ./libs/chartboost.jar
-keep class com.chartboost.sdk.** { *; }
I tried to compile project both on Mac & PC, but result is the same. Does anyone can help me with this issue?
Error has gone after update to beta version of their SDK.

Categories

Resources