in the program, if we use API interfaces above the Minsdkversion value, Eclipse will automatically notify the developer of the error. Here we take Getactionbar () As an example, this interface appears in Android 3.0 (API leve 11). We see the program's development tool (Eclipse) detection of the program by setting the value of Minsdkversion.
- As Minsdkversion = 8 o'clock, when we call the API level 13 interface, Eclipse automatically prompts the developer with an error:
Here we can choose [email protected] "NEWAPI" to deal with compilation errors through Eclipse's fix hint, but it is not recommended to solve the problem. This has escaped the compilation error, can successfully compile the apk file, but if the app is installed on a phone lower than the Android 3.0(API leve 13) system, it may cause a program crash ( higher than Android 3.0 (API leve 13) The system is installed on the phone properly). For an app to crash on the phone, it's better not to let the user install the app (personal view), of course, the need to consider the new API call frequency and the scene of a comprehensive sentence.
Here, Eclipse's @suppresslint ("Newapi") method is used to prevent error alerts.
The app crashes when you run it on an Android 2.3 (API Level 9) system.
all normal without error. When the Android system version is less than Android 3.0 (API level 11), the app will not install, and the Android system 3.0 or more is running properly.
2.3. Summary
We have seen the importance of minsdkversion from the above two points. minsdkversion not only works when the program is installed, it also works when the project is built . We should take full advantage of its two roles and carefully set its value to ensure that the application does not crash when running on some phones because of interface compatibility issues that affect the user experience .
3. Maxsdkversion
indicate the highest API level version that can run your app . It is not recommended to use this attribute in Google's official documentation.
on Android 1.5,1.6,2.0 and 2. 0. The system will check this value when installing an application or system upgrade on a 1 system. In both cases, if the maxsdkversion value of the app setting is lower than the API level used by the system itself, the system will not allow the app to be installed, and the new system will re-verify this value after the system upgrade, if the new system's API level is higher than this value, The new system will delete your app . On Android 2. 0.1 (API level 6) After the function of this attribute has been invalidated , it is also recommended not to use this property.
For example:
When you install the app on Android 2.3 (API Level 9), you can see that maxsdkversion is no longer working, and you can install the app when the system API is greater than maxsdkversion.
The new version of the system is basically completely compatible with previous versions of the old, there is no need to set this property to prevent your app from installing on the newer version, in addition, if you specify this property, A user's mobile system upgrade may erase your app . So this property is completely unnecessary to set up, which is probably why Google recommends no longer use it.
4. Targetsdkversion
This property tells the system that the application has been fully tested on a system with an API level of targetsdkversion value, and if the system has the same API and Targetsdkversion as the current application, The system will not enable compatibility mode to run the app, and if not set its default value will be equal to the value of minsdkversion.
Span style= "White-space:pre" > if the platform's API Level is higher than the value specified by the Targetsdkversion property in your application, the system turns on compatibility behavior to ensure that your application continues with your expect In general, the value of this property should be set to the latest API level value
Add new features when Android version update see:
Http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
If the platform's API level is lower than the value specified by the Targetsdkversion attribute in your application , the system will turn on compatibility behavior to ensure that your application works correctly. Then some of the features on the targetsdkversion are gone. However, this setting is only a declaration, a notification, and running in a low-version system will not be too substantial. For example: Using a feature in the SDK version of Targetsdkversion, but this feature is not supported in the low version, then when running the program on a lower version of the API device, you may get an error: Java.lang.VerifyError. That is, this property does not help you resolve the compatibility test problem. you need at least a complete run of the program on Minsdkversion this version to determine compatibility is no problem .
From the above discussion, targetsdkversion This attribute is in the program run time function, the system according to this property determines whether to run this program in compatibility mode.
5. Target
Android Project also has a target property, which is located in the Android project root directory project.properties, from the name it is easy to confuse its functionality and targetsdkversion.
In fact, they have different functions:
- Targetsdkversion This has been done analysis, in the program run, the system according to this property determines whether to run the program in compatibility mode.
- Project.Properties in the Target refers to the which version of the API is used for compiling when compiling . It is consistent with the API level of the API packages imported under the project. If you change the value of target, the API package will change, and the value of target will change when you change the API package.
6. Reference
(1) http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
(2) http://blog.csdn.net/zhangjg_blog/article/details/17142395
(3) http://blog.segmac.com/post/android-manifest-uses-sdk-element