flutter can't build APK with ProGuard - android

I just run flutter build apk --release
But build failed because of those warnings.
How can I fix these?
Anyone has an idea?
Warning: library class com.google.gson.Gson$6 extends or implements program class com.google.gson.TypeAdapter
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.Picasso
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.Picasso
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.Picasso$Priority
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.Picasso
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.RequestCreator
Warning: com.zhihu.matisse.engine.impl.PicassoEngine: can't find referenced class com.squareup.picasso.Picasso$Priority
Warning: com.zhihu.matisse.internal.model.SelectedItemCollection: can't find referenced class com.zhihu.matisse.R$plurals
Warning: com.zhihu.matisse.internal.model.SelectedItemCollection: can't find referenced class com.zhihu.matisse.R$plurals
Warning: com.zhihu.matisse.internal.ui.BasePreviewActivity: can't find referenced field 'int error_over_original_size' in program class com.zhihu.matisse.R$string
Warning: com.zhihu.matisse.internal.ui.BasePreviewActivity$2: can't find referenced field 'int error_over_original_count' in program class com.zhihu.matisse.R$string
Warning: com.zhihu.matisse.ui.MatisseActivity: can't find referenced field 'int error_over_original_size' in program class com.zhihu.matisse.R$string
Warning: com.zhihu.matisse.ui.MatisseActivity: can't find referenced field 'int error_over_original_count' in program class com.zhihu.matisse.R$string
ProGuard
#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.** { *; }

Related

Android proguard crashed when Azure mobile app is used

I use Azure mobile app in my new Android project.
When I run the app on debug mode, the Mobile app works successfully and I can see my new records in my table.
My problem is starting when I creates an apk file with proguard.
I am sorry to say that I am newbie on Proguard then I can not solve my Proguard problems even I read the documentation at offical Proguard page.
So, I get these errors when I try to create apk file with Proguard without any Proguard code.
Warning: com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable
Warning: com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable
Warning: com.google.common.base.Ascii: can't find referenced class javax.annotation.CheckReturnValue
Warning: com.google.common.base.CaseFormat$StringConverter: can't find referenced class javax.annotation.Nullable
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue
and more hundreads line...
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
and more hundreads line....
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Then I added these line in my proguard.
-keep class okio.** { *; }
-dontwarn okio.**
-keep class com.fasterxml.** { *; }
-dontwarn com.fasterxml.**
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe
-keep class com.microsoft.windowsazure.mobileservices.** { *; }
-dontwarn android.os.**
-dontwarn com.microsoft.windowsazure.mobileservices.RequestAsyncTask
After that, Android studio created the apk however The app crahsed as soon as It started. Then I investigate the logs, I saw new warnings that color are white.
Note: duplicate definition of library class [org.apache.http.conn.scheme.LayeredSocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException]
Note: duplicate definition of library class [org.apache.http.params.CoreConnectionPNames]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: duplicate definition of library class [org.apache.http.params.HttpConnectionParams]
Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class [android.net.http.HttpResponseCache]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [android.net.http.SslCertificate]
Note: there were 11 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Thanks for help.
#MustafaOlkun, It seems that the solutions for your issues can be found at the troubleshooting page of ProGuard.
For the issue Warning: can't find referenced class, please see http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass.
For the issue Note: duplicate definition of library class, please see http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass.
Hope it helps.

Is there an valid proguard rule for RxJava and FasterXML?

Now the only problem stopping me from using kotlin in production is that I can't find a correct proguard file for it.
What I used:
1.Kotlin
2.Anko
3.Jackson-Kotlin-module
Here's the warning message:
:app:proguardRelease
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.ConcurrentCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.ConcurrentSequencedCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.MpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.MpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.MpscLinkedQueue: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.SpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.SpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.SpscArrayQueue: can't find referenced class sun.misc.Unsafe
Warning: rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe
Warning: there were 41 unresolved references to classes or interfaces.
It has nothing to do with Kotlin. Ignore the warnings in your proguard file:
-dontwarn sun.misc.Unsafe
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
a better is just to have this aar as a dependency:
https://github.com/artem-zinnatullin/RxJavaProGuardRules

android -Progaurd return error 1

I want to use proguard for my application , I'm using eclipse . This is the config file :
-dontwarn com.parse.**
-keep class com.facebook.** {
*;
}
-keepattributes Signature
#When not preverifing in a case-insensitive filing system, such as Windows. This tool will unpack your processed jars,(if using windows you should then use):
-dontusemixedcaseclassnames
#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
-dontwarn android.support.**
#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose
#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.
#To repackage classes on a single package
#-repackageclasses ''
#Uncomment if using annotations to keep them.
#-keepattributes *Annotation*
#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
#Compatibility library
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** w(...);
}
#To avoid changing names of methods invoked on layout's onClick.
# Uncomment and add specific method names if using onClick on layouts
#-keepclassmembers class * {
# public void onClickButton(android.view.View);
#}
#Maintain java native methods
-keepclasseswithmembernames class * {
native <methods>;
}
#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
public <init>(android.content.Context);
}
-keep public class * extends android.view.View {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class * extends android.view.View {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
#Maintain enums
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#Keep the R
-keepclassmembers class **.R$* {
public static <fields>;
}
When I export the application and build the apk file ,it gives me the "Progaurd return error 1" and the in the consul it returns these errors :
Proguard returned with error code 1. See console
Warning: com.parse.FacebookAuthenticationProvider$1: can't find superclass or interface com.facebook.android.Facebook$ServiceListener
Warning: com.parse.FacebookAuthenticationProvider$2: can't find superclass or interface com.facebook.Session$StatusCallback
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find superclass or interface com.facebook.Request$Callback
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$Builder
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$Builder
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$Builder
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.SharedPreferencesTokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.SharedPreferencesTokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$Builder
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$Builder
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook$ServiceListener
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$StatusCallback
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.SessionDefaultAudience
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session$OpenRequest
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.TokenCachingStrategy
Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider$1: can't find referenced class com.facebook.android.Facebook$ServiceListener
Warning: com.parse.FacebookAuthenticationProvider$1: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.FacebookAuthenticationProvider$1: can't find referenced class com.facebook.android.FacebookError
Warning: com.parse.FacebookAuthenticationProvider$1: can't find referenced class com.facebook.android.FacebookError
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Session$StatusCallback
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request$Callback
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.Session
Warning: com.parse.FacebookAuthenticationProvider$2: can't find referenced class com.facebook.SessionState
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Response
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.FacebookRequestError
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Response
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.model.GraphObject
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Request$Callback
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Response
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.FacebookRequestError
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.model.GraphObject
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Request
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Response
Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find referenced class com.facebook.Response
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.Session
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.Session
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.Session
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.android.Facebook
Warning: com.parse.ParseFacebookUtils: can't find referenced class com.facebook.Session
You should check if you need to specify additional program jars.
Warning: there were 82 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
There are some external libraries that I use in my application , I just need the progaurd for obfuscation
Could you help me to solve this problem ?
Replace
-keep class com.facebook.** {
*;
}
with,
-dontwarn com.facebook.**

Android signed APK generation : Proguard exception for referenced class / method not found

I need to generate a signed APK for Play Store. ( using Android Studio )
If I do that without proguard ( minifyEnabled false in build.gradle ) all works fine!
If I activate it with default parameters :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I receive these warnings
:app:proguardRelease
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find superclass or interface com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced method 'java.lang.reflect.Type getType()' in program class com.android.volley.error.VolleyErrorHelper$1
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: there were 28 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 3 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Exception while processing task
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:473)
at proguard.ProGuard.initialize(ProGuard.java:233)
at proguard.ProGuard.execute(ProGuard.java:98)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:137)
at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:113)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
:app:dexRelease UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease
And the build process stop with this message :
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of ...\app\build\intermediates\classes-proguard\release\classes.jar
After several tentatives I've found a way to remove the warnings with this lines in my "proguard-rules.pro" :
-dontwarn com.android.volley.**
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
But the build process still goes in error!
Anyone have a workaround for this problem?
Thanks!
Davide
After several attemps ... here the solution :
First configure the dontwarn as suggested by Raymond ( maybe this is not necessary but i left it ) :
-dontwarn com.google.gson.**
-dontwarn java.nio.file.**
-dontwarn org.codehaus.mojo.animal_sniffer.**
-dontwarn com.squareup.okhttp.internal.huc.**
-dontwarn com.android.volley.error.**
Then configure Proguard to skip my library :
-keep class com.android.volley.error.** { *; }
-keep class com.squareup.okhttp.internal.huc.** { *; }
-keep class okio.** { *; }
Ather that the compilation was ok but on runtime the application crashed.
So, to avoid this problem, i've added these lines :
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**
based on some info found from this thread :
java.lang.RuntimeException: Could not inflate Behavior subclass
With this settings i'm able to generate a signed APK of my app.
You have to apply dontwarn to the referenced class instead.
For example:
-dontwarn com.google.gson.**
-dontwarn java.nio.file.**

Android using Parse.com - missing classes on Proguard

I am using Parse on a project. The project uses my own Android library project which has the Parse jars in it. When I try to generate a signed apk, gradle gives the following issue:
:exampleApp:proguardRelease Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
superclass or interface com.squareup.okhttp.RequestBody Warning:
com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.OkHttpClient Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.OkHttpClient Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.OkHttpClient Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.OkHttpClient Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.OkHttpClient Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't
find referenced class com.squareup.okhttp.Response Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.ResponseBody Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.ResponseBody Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Response Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Request$Builder
Warning: com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.ResponseBody Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Request Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.OkHttpClient Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient: can't
find referenced class com.squareup.okhttp.Response Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Request Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Request$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers$Builder Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Headers Warning: com.parse.ParseOkHttpClient:
can't find referenced class com.squareup.okhttp.Request Warning:
com.parse.ParseOkHttpClient: can't find referenced class
com.squareup.okhttp.Response Warning: com.parse.ParseOkHttpClient$1:
can't find referenced class com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient$1: can't find referenced class
com.squareup.okhttp.Call Warning: com.parse.ParseOkHttpClient$1: can't
find referenced class com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient$1: can't find referenced class
com.squareup.okhttp.Call Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class com.squareup.okhttp.RequestBody Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class com.squareup.okhttp.MediaType Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class okio.BufferedSink Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class com.squareup.okhttp.RequestBody Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class com.squareup.okhttp.MediaType Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class okio.BufferedSink Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class com.squareup.okhttp.MediaType Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class okio.BufferedSink Warning:
com.parse.ParseOkHttpClient$CountingOkHttpRequestBody: can't find
referenced class okio.BufferedSink Warning: there were 67 unresolved
references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
:exampleApp:proguardRelease FAILED
FAILURE: Build failed with an exception.
Edit:
Per #karama's suggestion, I added this to my proguard rules:
-keepattributes *Annotation*
-keepattributes Signature
-dontwarn com.squareup.**
-keep class com.squareup.** { *; }
-dontwarn com.parse.ParseOkHttpClient**
-keep class com.parse.ParseOkHttpClient** { *; }
# Proguard configuration for Jackson 2.x (fasterxml package instead of codehaus package)
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
Yet, now I get the following:
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: there were 5 unresolved references to classes or interfaces.
If I fix it with adding:
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
When the app runs, it crashes. I saw this issue here but with no resolution: https://stackoverflow.com/a/11249755/197127
Running the app with -dontobfuscate works fine.
The error is not of parse sdk, it occures because of okHttp. Add below lines in your proguard.
-keepattributes *Annotation*
-keepattributes Signature
-dontwarn com.squareup.**
-keep class com.squareup.** { *; }
Edit
for com.fasterxml.jackson add below code :
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
reference : https://github.com/krschultz/android-proguard-snippets/issues/19

Categories

Resources