Question

I'm receiving (from bugsense) crash reports from my App on Android versions below 3. But the App has declared in the manifest:

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />

So, as soon as the user makes a move, the App crashes.

How is that possible? I knew that install should fail with a "package analysis failed" message. Do I have to implement an in-App Android version check? Or am I missing something in the manifest?

an example:

0java.lang.NoSuchMethodError: xxx.xxx.xxx.MyActivity.getFragmentManager
1at xxx.xxx.xxx.MyActivity.onCreate(MyActivity.java:98)
2at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
3at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
4at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
5at android.app.ActivityThread.access$1500(ActivityThread.java:117)
6at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
7at android.os.Handler.dispatchMessage(Handler.java:99)
8at android.os.Looper.loop(Looper.java:123)
9at android.app.ActivityThread.main(ActivityThread.java:3729)
10at java.lang.reflect.Method.invokeNative(Native Method)
11at java.lang.reflect.Method.invoke(Method.java:507)
12at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
13at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
14at dalvik.system.NativeStart.main(Native Method)

I bet I don't have SuchMethod in Android 2.3.3

Anyway, total errors are only 3, upon about 1k users and 3,5k sessions per day, this week. So think about this Q as an exercise.

Was it helpful?

Solution

If the application is installed on a device that doesn't meet the specified API level, it will crash when executing code specific to a certain unsupported API level. However, specifying the minSdkVersion should prevent it from being installed at all on a device that doesn't meet this level.

However, using your "uses-sdk" definition above, it would also be possible for a device meeting the minimum SDK requirement to launch the app, but crash later on when you would use a method specific to the higher level of the target SDK (i.e. using a API level 17 method on a device which only meets the minimum requirement of level 11). If this were the case, you would have to use in-app checks or annotate methods using @TargetApi or a similar. However, seeing how you mention you receive crashes from Android versions below the minimum SDK level, something else seems to be amiss.

Not trying to be funny: but can you confirm that all versions of this application (that have been made available to the public) included the "uses-sdk"-declaration as described in your post ? It might be the case that an older version of the application has crashed and you're not reading the bug report for the newest available APK but a previous version...

OTHER TIPS

Whenever you are using Android versions below 3. You need to use lower minSdkVersion to 8.

<uses-sdk  android:minSdkVersion="8" 
    android:targetSdkVersion="17" />

Use this, it will work for all Android versions devices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top