Skip to content Skip to sidebar Skip to footer

Compile Android Project With A Higher Sdk

I have a question about android sdks. I'm developing an android application and it must be work on Android 2.3.3 and higher. Because I need to use 'android-support-v7-appcompat' li

Solution 1:

In any case you should properly define minSDK and targetSDK in manifest file. When you compile for example with API 19 (KitKat) and you set as minSDK API 10 everything should work on your 2.3.3 Android.

However if you used in your code some methods, constants that are not available on 2.3.3 you will get warnings/errors in Eclipse (I bet in Android Studio as well). For example:

if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        // before JELLY_BEAN_MR2 code;// methods, constants available for example from API 1
    } else {
        // after JELLY_BEAN_MR2 code// here are new methods,constants available from GINGERBREAD_MR1 and after
    }

so here your app will execute something in a two different way depending on Android version it is running on... In case you don't compile with API equals or higher of JELLY_BEAN_MR2 you would not even be able to compile because before, constant JELLY_BEAN_MR2 was not available in API... However when you compile with higher API everything will be compiled properly and app will work on earlier versions without problems.

If you leave code like this warning will appear but @SuppressLint("NewApi") before calling method should remove it with no further problems.

Hope it helped and it is clear now.. ;)

Cheers

Solution 2:

Its Depends on your target selected for ex:

<uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="19" />

Post a Comment for "Compile Android Project With A Higher Sdk"