0

Application getting crashed on enabling minifyEnabled true. When I make it false application starts working fine. Do I need to add something to my pro-guard file? I am not able to figure out what is causing an application to crash.

Here is the Gradle code:

debug {
            manifestPlaceholders = [crashlyticsApiKey: '', mapApiKey: '']
            // Enables code shrinking, obfuscation, and optimization for only
            debuggable true
            // your project's release build type.
            minifyEnabled true
            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            buildConfigField "String", "BASE_URL", '"http://"'
            signingConfig signingConfigs.debug
        }

Logcat Output:

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:309)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.ExceptionInInitializerError
        at l.b.g.f$a.<init>(:372)
        at l.b.g.f.<init>(:19)
        at l.b.h.m.a(:32)
        at l.b.h.m.b(:42)
        at l.b.h.b.b(:56)
        at l.b.h.g.a(:32)
        at l.b.f.a.a(:135)
        at l.b.f.b$d.f(:747)
        at l.b.f.b.b(:250)
        at d.k.a.i.g.a(:36)
        at d.k.a.i.g.doInBackground(:17)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
     Caused by: java.lang.IllegalStateException: Could not read resource entities-xhtml.properties. Make sure you copy resources for l.b.g.i
        at l.b.g.i.b(:301)
        at l.b.g.i.a(:25)
        at l.b.g.i$b.<init>(:53)
        at l.b.g.i$b.<clinit>(:34)
        at l.b.g.f$a.<init>(:372) 
        at l.b.g.f.<init>(:19) 
        at l.b.h.m.a(:32) 
        at l.b.h.m.b(:42) 
        at l.b.h.b.b(:56) 
        at l.b.h.g.a(:32) 
        at l.b.f.a.a(:135) 
        at l.b.f.b$d.f(:747) 
        at l.b.f.b.b(:250) 
        at d.k.a.i.g.a(:36) 
        at d.k.a.i.g.doInBackground(:17) 
        at android.os.AsyncTask$2.call(AsyncTask.java:295) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
02-10 15:19:58.687 17254-20516/? E/cjle: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*
        Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
02-10 15:20:25.416 17254-28037/? E/WakeLock: GCM_HB_ALARM release without a matched acquire!

Please let know what is wrong in my code.

Thanks

user2028
  • 163
  • 4
  • 15
  • 40
  • can you post the code for asynctask? – Zaartha Feb 10 '20 at 09:58
  • Does this answer your question? [Android JSOUP ExceptionInInitializerError](https://stackoverflow.com/questions/40703857/android-jsoup-exceptionininitializererror) – PPartisan Feb 10 '20 at 10:03

1 Answers1

1

The error stack indicates this: Caused by: java.lang.IllegalStateException: Could not read resource entities-xhtml.properties. Make sure you copy resources for l.b.g.i

I think this is because the resource/class l.b.g.i is excluded by ProGuard. You may want to use mappings.txt file (that contains mapping between actual class/method name and its random one generated by proGuard) to decode actual resource name and then force Proguard to keep it, something like this example https://stackoverflow.com/a/5866755/1992013 Hope this helps !

Birender Singh
  • 513
  • 6
  • 16
  • Did u try swithcing off shrinkResources ? u might have to troubelshoot by looking at proGuard output files https://developer.android.com/studio/build/shrink-code.html to understand further. it could be related to data classes obfuscation reference: https://blog.mindorks.com/things-to-care-while-using-proguard-in-android-application. Here is sample proguard file https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro – Birender Singh Feb 10 '20 at 12:41