0

I currently cannot recreate this error on my physical device (S6). Things work fine for me and the changes I have made do not seem to be solving this issue. I have the following error:

java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:300)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ExceptionInInitializerError
    at a.a.b.m.a(Unknown Source)
    at a.a.b.p.<clinit>(Unknown Source)
    at a.a.b.g.<init>(Unknown Source)
    at a.a.b.f.<init>(Unknown Source)
    at a.a.c.di.b(Unknown Source)
    at a.a.c.di.a(Unknown Source)
    at a.a.c.b.a(Unknown Source)
    at a.a.c.ae.a(Unknown Source)
    at a.a.a.a.a(Unknown Source)
    at a.a.a.f.e(Unknown Source)
    at a.a.a.b.a(Unknown Source)
    at com.airborne.grgr4.f.a(Unknown Source)
    at com.airborne.grgr4.f.doInBackground(Unknown Source)
    at android.os.AsyncTask$2.call(AsyncTask.java:288)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    ... 4 more
Caused by: java.lang.NullPointerException: in == null
    at java.util.Properties.load(Properties.java:246)
    at a.a.b.m.d(Unknown Source)
    at a.a.b.m.<clinit>(Unknown Source)

I know this is quite a common error when trying to update the UI from a background thread or some other threading misuse. What is messing me up is that I cannot recreate this error on my Galaxy S6 so I cannot properly fix it. Here is my async code:

new selectRepsBasedOnZipCode().execute(zipCode);

^^Calling method.

    private class selectRepsBasedOnZipCode extends AsyncTask<String, Void, ArrayList<String>> {

    protected ArrayList<String> doInBackground(String... params) {
        ArrayList<String> UserRepsBasedOnZip = new ArrayList<String>();

        String firstPartOfURL = "https://www.opencongress.org/search/result?q=";
        String lastPartOfURL = "&search_people=1";
        String urlToParse = firstPartOfURL + params[0] + lastPartOfURL;

        try {
            Document doc = Jsoup.connect(urlToParse).get();
            Elements content = doc.getElementsByClass("name");

            for (Element name : content) {
                UserRepsBasedOnZip.add(name.childNode(0).toString().trim());
            }
        } catch (Exception ex) {
            return UserRepsBasedOnZip;
        }
        return UserRepsBasedOnZip;
    }

    @Override
    protected void onPostExecute(ArrayList<String> UserRepsBasedOnZip) {
        finishBuildingLocalRepPage(UserRepsBasedOnZip);
    }
}

I am using JSoup to do some of this work. As I said I cannot recreate the issue (Program is compiled from Android Studio on my device as the latest version) but others I know that have the app report this crash.
This is the only Async method I have in this stage of events, so this leads me to believe that this must be the place the crash is happening. Any feedback or suggestions on a fix and how to verify the fix would be great, thanks.
+Bonus if you can explain why this works flawlessly on my device (S6) but fails on all other devices (L-01F, Galaxy Tab A 8.0, Galaxy S4, HTC One).

Adam
  • 490
  • 7
  • 21

2 Answers2

1

The problem is ProGard, when you ofuscate jsoup code. Just check this answer : https://stackoverflow.com/a/15199658/4848308

Check this question too jsoup code works in Java but not in Android- Nullpointerexception

I hope it help!!!

Community
  • 1
  • 1
Gueorgui Obregon
  • 5,077
  • 3
  • 33
  • 57
  • g2o, this seems like a likely candidate for the issue. I will update when I can test this out, thanks. – Adam Jan 26 '16 at 17:56
  • Perfect answer g2o! I confirmed by deploying the release version on my phone from Android Studio, it crashed... Then added the -keep for jsoup to the proguard file, worked like a charm! Additional reference: http://stackoverflow.com/questions/14343448/using-jsoup-with-proguard-closing-force-close – Adam Jan 27 '16 at 02:15
-2

i suggest you should trace error using Log.e() or Log.i(). You will get it for reference you can refer blog which i have refer for AsyncTask

  • It is a deployed app, as far as I know deployed apps should not have logging like this in them. The stack trace is a crash report from the Android Console so local logging like this would not help. – Adam Jan 26 '16 at 16:55