2

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.

Community
  • 1
  • 1
checklist
  • 12,340
  • 15
  • 58
  • 102

1 Answers1

4

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

Karan Maru
  • 991
  • 6
  • 17
  • Thanks Karan. Can I also add this for com.fasterxml.jackson ? – checklist Jun 06 '15 at 11:20
  • Thanks for the update which took me a step further. But now I have the app crash when running. I updated the question with the details. – checklist Jun 06 '15 at 16:01
  • please update your proguard by this answer : http://stackoverflow.com/a/11032856/1944782 – Karan Maru Jun 07 '15 at 20:26
  • Hi Karan. Thanks again. But I still get the following: java.lang.NoSuchFieldError: PUBLIC_ONLY at java.lang.Class.getDeclaredAnnotation(Native Method) at java.lang.Class.getAnnotation(Class.java:290) at com.fasterxml.jackson.databind.f.al.(Unknown Source) at com.fasterxml.jackson.databind.ObjectMapper.(Unknown Source) – checklist Jun 08 '15 at 07:42