Setting the correct Android API level for my project

In my application, I want to configure all versions of Android> = 8 (Push-Notification is required), but I find it difficult to understand the correct combination of API / dependencies that I need for my project setup.

The project will require the Google API for location-based services, and I need / need to use ActionBarSherlock to support ActionBar.

Is this setting correct?


AndroidManifest.xml:

(1)

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /> <application android:theme="@style/Theme.Sherlock.Light" > ... 

Libs:

(2) I added android-support-v4.jar

Project properties:

(3) Install Google API 16

ActionBarSherlock:

(4) I watched the video in the ActionBar-FAQ to configure ABS as a library project, and I installed it in Android level 16 in its project fault and added android-support-v4.jar to my lib folder.


I know this is one of the main questions, but I'm not sure I chose the right setting. I am particularly interested in whether (3) is correct, or if I have to set the general API level to 8?

Update 1 . I also have a problem understanding the support.jar mechanisms. If I set the max build goal, how should the system make sure that high-level functionality (like fragments) works in lower APIs (like 8). Is this done automatically, or do I need to manually encode support packages? Update 2. Regarding support.jar , I will need to know what functions I use and I will have to encode the support file. If I refuse and use too complex a function, a ClassCastException at lower levels of the API will be thrown ...?

Any help appreciated. Also: I'm a beginner, so answers with some background information would be much appreciated :)

Thanks!

+1
source share
3 answers

It looks right. As described in the video on ActionBarSherlock.com, you want your step # 3 to be set to the highest "project build target" available for your version of ActionBarSherlock. Therefore, if you have ABS 4.1.0, you need platform 4.1, API 16.

Did you also create an ABS project as a library? Your project dependencies should have both:

  • <Your-ABS Library> .jar
  • Android Support-v4.jar
+1
source

Your setting is correct. If you install it on version 8 (3), you cannot compile it. Since ActionBarSherlock is required at least api level 14.

But setting it this way, you need to consider one thing: all the Android APIs that you use must be API <= level 8. That is, you cannot use a function that is not included in API level 8, otherwise the application will crash using ClassNotFoundException or MethodNotFound exceptions.

As for the snippet, you should always select the Snippet support library. That is, you should import android.support.v4.app.Fragment, not android.app.Fragment.

For update 2:

Yes, it will be launched at runtime, which will render your applications inoperative. But I'm pretty sure that you can avoid this error by checking the current API level for the phone.

for instance

 if(android.os.Build.VERSION.SDK_INT >= 11) { // API that supported in API >= 11 } else { // API that supported in API < 11 } 

I really confirmed it myself. You can try to test it using the emulator, for example, run the 8th version emulator and run the code with API version> = 8.

+1
source

I would recommend you install the Build SDK in API 15. I also use this with the Sherlock ActionBar, and everything works fine.

0
source

All Articles