Difference between “Build Target SDK” in Eclipse and android:targetSdkVersion in AndroidManifest.xml?

后端 未结 7 503
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 02:55

As I\'m importing an existing Android project into Eclipse, I am asked to select an SDK build target as part of the process.

Why do I need to enter this information?

7条回答
  •  死守一世寂寞
    2020-12-05 03:40

    android:minSdkVersion in manifest file means that market will filter devices with lower sdk.

    target=android-x in project properties file means that Eclipse will not allow use methods or classes from sdk higher than x. It will show compiler errors.

    You can use it like this: provide min version in manifest - depending on your app critical features. Set the same value to project properties. Then, if you want use somewhere APIs from higher SDKs - raise up value in project properties, and wrap code with check if device API can do this code:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1)
    {
        // here you can use APIs, that appears in Android 2.1
    }
    

提交回复
热议问题