missing EOF at '-keepclass' proguard android - android

when I add one line in proguard file its showing error Error:com.android.build.gradle.shrinker.parser.ProguardParserException: ProGuard configuration parser error: /root/projectDirectory/myprojectname/app/proguard-rules.pro line 42:0 missing EOF at '-keepclass'.
If I remove this file it shows Error :
Method code too large.
The project builds successful without proguard.
Any suggestion ??
Thanks.

This is because you're using an invalid rule with something like:
-keepclass com.example.activity {*;}
it should be
-keep class com.example.activity {*;}

Related

Unable to generate signed APK : Can't find common super class of [com/google/android/gms/internal/zzmk]

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?

Android Crashlytics sending incorrect line number

I'm trying to integrate Crashlytics with my app and it's working, however the line number passed through seems to be incorrect. This is a stack I'm getting for my test exception:
Fatal Exception: java.lang.RuntimeException: This is a test crash
at com.myapp.testapp.activity.MainActivity.animateReveal(MainActivity.java:42453)
at com.myapp.testapp.activity.MainActivity.onClick(MainActivity.java:1356)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
So my crash is on line number 1453 but for some reason it's showing up as 42453? Interestingly, the next line number in the stack is correct...
Proguard:
# Crashlitics
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keepattributes *Annotation*
To preserve the information that Firebase Crashlytics SDK requires for producing readable crash reports, add the following lines to your Proguard or Dexguard config file:
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.
Likely it's because you're using a release build which will remove comments/ white spaces.
If you're using a debug build then it may show the correct lines, because it won't optimize your source code...
Still I'm guessing there is another reason for the line numbers to show incorrect, because Fabric was telling me the crash was happening at line 400, even though that function was called at line 300. I mean if comments and white spaces are to be removed, Fabric should have told line some line less than 300, not more!
In my case switching from 'proguard-android-optimize.txt' default proguard file to 'proguard-android.txt' fixed the issue. Using the optimized version of the proguard file can introduce certain risks and it seems that this is one of them.
Did you try this?
For Fabric to properly de-obfuscate your crash reports, you need to
remove this line from your configuration file, or we won’t be able to automatically upload your mapping file:
-printmapping mapping.txt
and
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
I had same issue, a simple observation solve my issue, see proguard-rule and uncomment these line
(-keepattributes SourceFile,LineNumberTable)
and
(-renamesourcefileattribute SourceFile)

Proguard keep fails about excluded .jar class

I made a simple app with external .jar library.
And going to obfuscator work with ProGuard.
But stuck with errors even had proguard rules.
I don't even know "borken class file" meaning about....
Can anyone know about this problem? Thanks. (Setting options or config attached as bottom section)
# Messages at Android Studio
Error processing C:\Users\administator\Desktop\artest\app\src\main\libs\arsupport.jar:ac.class: broken class file?
Error processing C:\Users\administator\Desktop\artest\app\src\main\libs\arsupport.jar:am.class: broken class file?
...
...
More similar errors...
...
...
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Can't read [C:\Users\administrator\Desktop\artest\app\src\main\libs\arsupport.jar(;;;;;;**/*.class)]
(Can't process class [com/arsec/Programsupport.class] (Unknown verification type [46] in stack map frame))
and ProGuard rules
# proguard-rules.pro
-keep class com.arsec.** { *; }
-keep interface com.arsec.** { *; }
-dontwarn com.arsec.**
I got the same issue in my project,some suggest to reset the value ATTR_StacjMapTable to "dummy" in ClassConstants.java .then repack the proguard.jar
But I solve the problem is get the latest ProGuard in [http://proguard.sourceforge.net the use the latest proguard to make jar. goodlucky

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

CrashLytics not showing crash reason

I am using crashlytics in my app. It caught a crash in the app, but not telling the line of code where crash occured. It is showing the verify error, but not telling where it is. This link is a screenshot to the report. It is showing ??? about the crash, see this link. How to study this crash now? ._.
Preserve annotations, line numbers, and source file names
-keepattributes *Annotation*,SourceFile,LineNumberTable
If you are using custom exceptions, add this line so that custom exception types are skipped during obfuscation:
-keep public class * extends java.lang.Exception
-printmapping mapping.txt
To skip running ProGuard on Crashlytics, add the following.
This will help speed up builds so that we can ship and test even faster.
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
More Info: Follow this link to Configure Crashlytics with Proguard.
https://docs.fabric.io/android/crashlytics/dex-and-proguard.html

Categories

Resources