2

How can a production app show a class not found error to users but on the emulator it works just fine with Android 9.0. Shouldnt the emulator also break or show an error during compiling or building?

java.lang.RuntimeException:

at android.os.AsyncTask$3.done (AsyncTask.java:354) at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383) at java.util.concurrent.FutureTask.setException (FutureTask.java:252) at java.util.concurrent.FutureTask.run (FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764)

Caused by: java.lang.NoClassDefFoundError:

at org.apache.http.impl.client.AbstractHttpClient. (AbstractHttpClient.java:182) at org.apache.http.impl.client.DefaultHttpClient. (DefaultHttpClient.java:150) at com.exposure.utilities.RestClient.executeRequest (RestClient.java:162) at com.exposure.utilities.RestClient.Execute (RestClient.java:127)
at com.exposure.utilities.Utility.getData (Utility.java:162) at com.exposure.utilities.DataTask.doInBackground (DataTask.java:26) at com.exposure.utilities.DataTask.doInBackground (DataTask.java:9) at android.os.AsyncTask$2.call (AsyncTask.java:333) at java.util.concurrent.FutureTask.run (FutureTask.java:266)

Caused by: java.lang.ClassNotFoundException:

at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass (ClassLoader.java:379) at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

2
  • Is this happening on device with android pie? Commented Nov 29, 2018 at 12:02
  • Yes, but I have 450 apps, why in the world would it be throwing an error on load where no one can use it? Commented Nov 29, 2018 at 12:46

1 Answer 1

2

It looks like this is due to http client being deprecated. Add below code to your manifest application tag.

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

With android pie they have deprecated support for Apache HTTP client starting from andorid pie, check change log for reference https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p

Sign up to request clarification or add additional context in comments.

3 Comments

This is Android 9 and mainly on Pixel 1, 2 and 3. Why in the world would I be able to submit an app to the store that would crash on load? Emulator worked just fine.
Android 9 works fine, without that update in the emulator, no crash.
I went ahead and updated the http connection code to the non deprecated one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.