Can I run my app on API 23 if target SDK version I

2019-03-01 12:26发布

问题:

I have developed an Android App having API 21 as target SDK version.

Will it run fine on API above it, for example, API 23?

回答1:

It is perfectly ok to use a targetSdkVersion and install it on a device that has a greater SDK version.

The targetSdkVersion that you specified in your build.gradle tells the system that you have developed and tested your app to work on that SDK. If the user installs your app on a greater SDK it is the system responsibility to provide backwards compatibility (if anything has changed).

A good example is what happened with the permissions on SDK 23. Since that version it is necessary to explicitly request for dangerous permissions in code, just declaring the permission in the manifest is no longer sufficient.

However, if you target this app to SDK22, it is not required to request explicitly by code, and if you install this app on a greater SDK system, it will work, because of the backward compatibility, which in this case is to accept all the permissions at install time.



回答2:

According to Uses SDK

android:targetSdkVersion

An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion. This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).

It could also help you to know this

android:minSdkVersion

An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute. You should always declare this attribute.



回答3:

Your minSdkVersion is certainly below the API 21. So, your application does work on above SDK versions (including the API 23).

You're good with that, no worries :)

PS: Check this link targetSDKVersion to learn more about target SDK use purpose.