Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when releasing APK with AsyncTask and Jsoup

I'm getting this error:

03-04 09:55:55.915: W/dalvikvm(20171): Exception Ljava/lang/NullPointerException; thrown while initializing La/a/b/k;
03-04 09:55:55.915: W/dalvikvm(20171): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing La/a/b/l;
03-04 09:55:55.925: W/dalvikvm(20171): threadid=13: thread exiting with uncaught exception (group=0x40ab3300)
03-04 09:55:55.945: E/AndroidRuntime(20171): FATAL EXCEPTION: AsyncTask #1
03-04 09:55:55.945: E/AndroidRuntime(20171): java.lang.RuntimeException: An error occured while executing doInBackground()
03-04 09:55:55.945: E/AndroidRuntime(20171):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.lang.Thread.run(Thread.java:856) 03-04 09:55:55.945: E/AndroidRuntime(20171): Caused by: java.lang.ExceptionInInitializerError
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.b.f.<init>(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.b.e.<init>(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.c.dh.b(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.c.dh.a(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.c.b.a(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.c.ad.a(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.a.a(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at com.taco.bezoekerspasparkeren.c.a(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at com.taco.bezoekerspasparkeren.c.doInBackground(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-04 09:55:55.945: E/AndroidRuntime(20171):    ... 5 more
03-04 09:55:55.945: E/AndroidRuntime(20171): Caused by: java.lang.ExceptionInInitializerError
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.b.l.<clinit>(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    ... 16 more
03-04 09:55:55.945: E/AndroidRuntime(20171): Caused by: java.lang.NullPointerException
03-04 09:55:55.945: E/AndroidRuntime(20171):    at java.util.Properties.load(Properties.java:246)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.b.k.d(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    at a.a.b.k.<clinit>(Unknown Source)
03-04 09:55:55.945: E/AndroidRuntime(20171):    ... 17 more
03-04 09:55:55.995: W/ActivityManager(265):   Force finishing activity com.taco.bezoekerspasparkeren/.BezoekerspasActivity

With this piece of code:

class Subscribe extends AsyncTask<String, Void, Result> {

        @Override
        protected Result doInBackground(String... s) {
            // ...

            Document test = Jsoup.parse("<html></html>"); // explodes here
        }
}

This is only in release mode. I'm using Jsoup 1.7.2. What is wrong? And how can I see the errors collapsed in "... 17 more" since I guess the clue lies there...

This is the same question as error using AsyncTask only when running release apk... please help :( but it is unanswered.

This one is cracking me!

like image 890
Taco de Wolff Avatar asked Mar 04 '13 09:03

Taco de Wolff


1 Answers

It was indeed an obfuscation problem by ProGuard (which is logical if the problem exists in release-mode only), I had to add the following to the proguard file:

-keep public class org.jsoup.** {
    public *;
}
like image 132
Taco de Wolff Avatar answered Oct 07 '22 23:10

Taco de Wolff