Is there an valid proguard rule for RxJava and FasterXML? - android

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

Related

Getting com.loopj.android.http.AsyncHttpClient after enabling Proguard

I have read this, It looks like its a known issue from quite some time. But i was not receiving any warning or crash when i was not using pro-guard. After enabling it, I am receiving around 500 warnings like following;
Warning:com.loopj.android.http.AsyncHttpClient: can't find referenced
class cz.msebera.android.httpclient
I have tried following, but still all of the warnings are there.
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
}
I am not using http-client library, but there may be some other library that I am using in my project is using this.
Warnings
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpResponse
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.Header
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.StatusLine
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpResponse
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpEntity
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.client.methods.HttpUriRequest
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.protocol.HTTP
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.utils.URLEncodedUtils
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.utils.URLEncodedUtils
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.HttpEntity
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
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.SpscArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueueProducerFields: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.conn.scheme.HostNameResolver
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.params.HttpParams
Warning:library class org.apache.http.params.HttpConnectionParams depends on program class org.apache.http.params.HttpParams
Warning:there were 757 unresolved references to classes or interfaces.
Warning:there were 18 instances of library classes depending on program classes.
Warning:there were 8 unresolved references to program class members.
Warning:there were 2 unresolved references to library class members.
After adding the lines provided in Hitesh Gehlot answer. I am receiving these 5 warnings.
Information:Gradle tasks [:app:assembleRelease]
Warning:com.algolia.search.saas.APIClient: can't find referenced method 'org.json.JSONObject put(java.lang.String,java.util.Collection)' in library class org.json.JSONObject
Warning:com.algolia.search.saas.Index: can't find referenced method 'org.json.JSONObject put(java.lang.String,java.util.Collection)' in library class org.json.JSONObject
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:there were 3 instances of library classes depending on program classes.
Warning:there were 2 unresolved references to library class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
paste these lines in proguard-rules.pro file
-dontwarn com.loopj.android.http.**
-dontwarn org.apache.http.**
-dontwarn rx.internal.util.**

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.

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

gradle - proguard errors do not reflect -dontwarn

gradle 1.10 on linux on CLI
./gradlew clean
./gradlew assembleRelease
ERROR in stdout...
Note: there were 2 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 5 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 106 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
:proguardRelease FAILED
:proguardRelease (Thread[main,5,main]) completed. Took 4.689 secs.
FAILURE: Build failed with an exception.
I extend an oss package bundled with gradle for release builds ( added jackson.json but not from maven central ).
For some reason, proguard is throwing hundreds of 'org.joda.time... class not found' errors despite the following snips:
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
} // in 'build.gradle'
-dontwarn android.support.**
-dontwarn org.joda.time.**
-dontwarn org.codehaus.jackson.**
-dontwarn ch.boye.httpclientandroidlib.**
-dontwarn org.apache.http.**
-dontwarn android.**
-dontwarn java.**
-dontwarn com.google.sample.castcompanionlibrary.**
-dontwarn org.w3c.dom.**
-dontwarn com.google.android.gms.maps.**
#rcr adds
-libraryjars /usr/local/src/android-sdk-linux/platforms/android-19/android.jar
-libraryjars <java.home>/lib/rt.jar
-libraryjars libs/jackson-core-lgpl-1.9.2.jar
-libraryjars libs/jackson-mapper-lgpl-1.9.2.jar
-libraryjars libs/Parse-1.1.3.jar
-libraryjars libs/httpclient-1.1.jar
stdout DETAIL from './gradlew assembleRelease' below:
Initializing...
Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'Object'
Maybe you meant the fully qualified name 'java.lang.Object'?
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableDateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableInstant
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warn
... 100s more in 'org.joda.time.**'
Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImplGmm6
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImpl
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentNavigableMap
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentSkipListM
The -dontwarn proguard configs for 'org.joda.**' dont seem to work..
I have "-dontnote **ILicensingService" in config and that does not appear to work.
The -dontwarn config for com.google.android.gms.** not working
The -dontwarn for java.util.** not working
In what file is your "snippet" with the -dontwarn flags? It doesn't look like you're ever telling your build.gradle file about that proguard configuration.
You have:
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
But you should also have:
proguardFile 'your_proguard_config.cfg'
so that it will use both the default android configuration and your configuration.

Categories

Resources