3

I have android app in market so I get this error but I don't know why.

Exception class java.lang.NoClassDefFoundError
Source method MainActivity.onCreate()

java.lang.NoClassDefFoundError: android.app.DownloadManager
at com.example.viewpagerexample.MainActivity.onCreate(MainActivity.java:182)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

1 Answer 1

3

DownloadManager was added on API level 9 (aka Gingerbread). My guess you declared minSDK as lower than 9 in your AndroidManifest.xml

If that is the case, you need to devise a workaround for users using older Android version. You can check on which version your app is running by using the following code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    // Use DownloadManager
}
else {
    // Workaround
}
Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome. Please consider accepting my answer if it was helpful to you.

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.