简体   繁体   中英

does the target SDK option in android SDK have to be the same as the test device Android version? (Android SDK basic)

I need to tell someone how to setup the Android SDK through email. I do all my testing on the latest device and my programs all compile properly for my settings, but I don't know what device they have and which exact android version (however I am sure they probably have at least Android 4.0, but might have something older, such as Android 2.3 as well). To run the most basic Hello World program (or any other program that I test on my latest device for that matter), in the New Android Application dialogue box, do i have to select to select the exact same version of Android that they have with them, or can it be something higher than what they have in their device?
在此输入图像描述

Will the program still compile and run if they choose something higher than what is on their device? I must point out that no matter what device they have or what ever program they will be compiling, they will only be using classes provided in the older API's (API 1 - 3). So does it make any difference what I select here, or does it have to be exactly what is on their device or older?

I do not have another Android device for me to test it with, so your help will be greatly appreciated. Thank you.

android:minSdkVersion — Specifies the minimum API Level on which the application is able to run.

android:targetSdkVersion — Specifies the API Level on which the application is designed to run.

Your device does not have to match the targetSdkVersion. However, generally you want to set the targetSdkVersion to the latest Android version. To ensure the application will run on older devices, be sure to use the Android Support Library that backports newer functionality to older API levels.

You can read more about uses-sdk to learn more about the API level to target.

You should set the minimum SDK required to whatever API is required for all code to work correctly. Some API methods are not available until later versions and some have been deprecated in current versions (though the deprecated methods should still work as expected). No devices that I know of require API 1-3. Most devices all have 8 or higher. The target SDK is the code you are targeting when you program so say if new APIs have become available and you are using them in your code then you won't get a compile time error saying the method/class doesn't exist. You should also be aware that if you target a higher API then will be running on the device, you may have run time errors of methods/classes not existing.

To run your app, your device must be equal to or higher than you Minimum SDK

Your Target SDK is the one against which the app is compiled against. Keep in mind that using a higher SDK makes it possible for you to use newer API features in your app and compile successfully, and then run into runtime errors on your older devices. This can be managed using if else statements to test the API before using newer classes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM