I have read the Android documentation here and this similar question here, but have a question on the real life implications of this version.
My app had a targetSdkVersion of 25 while in development, and I was trying it out with a SDK level 27 (Android 8.1) phone with no issues.
My question is specifically about broadcast receivers. Prior SDK 26, you can register for broadcasts in manifest file and you will receive all the broadcasts you registered for. But 26 changed that to severely limit this mechanism that you cannot receive any implicit broadcasts, like Wifi connection changes. And instead they recommend using JobScheduler, with a minimum period of 15 minutes. This would absolutely not work for my app.
Now what I want to understand is, what are the implications of releasing my app with a target SDK version of 25, given that I do not use any features of latest SDK (27)?
Would there be any restrictions for a phone running SDK > 25 to use my app?
Thank you.
The scenario you are mentioning is know as forward compatibility in Android. You can think it in other way as well, you app is already in Google Play Store and user updated his device software. In such case, Android/Google strongly focus on that existing apps built against prior SDKs should not break when the user updates to a new version of Android.
If any API of API level 25 you are using in your app is not deprecated in API level 27, there is no issue. It is completely fine to set targetSdkVersion : 25.
But it is always recommended to compile your app with latest available SDK so that you can minimize the risk of crash/warnings of your code with respect to latest SDK.
So basically what you should follow is:
minSdkVersion <= targetSdkVersion <= compileSdkVersion
Hope this will help you.
When you run your application on a version of on Android that have a higher version than the targetSdkVersion specified this may lead to some issues.
For example, if the targetSdkVersion is less than 14, your app may get an option button in the UI.
Thus, to have the compatibility of the android version you better need to set the compileSdkVersion and targetSdkVersion the same.
Related
If I am currently developing an SDK module for an Android application, do I still need to set my targetSdkVersion to 26 from now on in order for the client application to approve (from Nov 2018)?
Short answer: No. From the developers post the app is the only thing required to be targeting API 26.
What could happen is the following scenario: imagine that your module is targeting an old API level and uses a deprecated method. If your app targets a more recent API where that method was removed, your app may not compile.
Hope this can help you. Cheers!
I have looked at the documentation for building with Gradle, but I'm still not sure what the difference between compileSdkVersion and targetSdkVersion is.
All it says is:
The `compileSdkVersion` property specifies the compilation target.
Well, what is the "compilation target"?
I see two possible ways to interpret this:
compileSdkVersion is the version of the compiler used in building the app, while targetSdkVersion is the "API level that the application targets". (If this were the case, I'd assume compileSdkVersion must be greater than or equal to the targetSdkVersion?
They mean the same thing. "compilation target" == "the API level that the application targets"
Something else?
I see that this question has been asked before, but the one answer just quotes the doc, which is what is unclear to me.
compileSdkVersion
The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.
targetSdkVersion
The targetSdkVersion has nothing to do with how your app is compiled or what APIs you can utilize. The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify. This is more like a certification or sign off you are giving the Android OS as a hint to how it should handle your app in terms of OS features.
For example, as the documentation states:
For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher...
The Android OS, at runtime, may change how your app is stylized or otherwise executed in the context of the OS based on this value. There are a few other known examples that are influenced by this value and that list is likely to only increase over time.
For all practical purposes, most apps are going to want to set targetSdkVersion to the latest released version of the API. This will ensure your app looks as good as possible on the most recent Android devices. If you do not specify the targetSdkVersion, it defaults to the minSdkVersion.
As a oneliner guide:
minSdkVersion <= targetSdkVersion <= compileSdkVersion
Ideally:
minSdkVersion (lowest possible) <= targetSdkVersion == compileSdkVersion (latest SDK)
Read more from this great post by Ian Lake
Late to the game.. and there are several great answers above-- essentially, that the compileSdkVersion is the version of the API the app is compiled against, while the targetSdkVersion indicates the version that the app was tested against.
I'd like to supplement those answers with the following notes:
That targetSdkVersion impacts the way in which permissions are requested:
If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the app requests permissions from the user at run-time.
If the device is running Android 5.1 (API level 22) or lower, or the app's targetSdkVersion is 22 or lower, the system asks the user to grant the permissions when the user installs the app.
If the compileSdkVersion is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect. (ref)
With each new Android release...
targetSdkVersion should be incremented to match the latest API level, then thoroughly test your application on the corresponding platform version
compileSdkVersion, on the other hand, does not need to be changed unless you're adding features exclusive to the new platform version
As a result, while targetSdkVersion is often (initially) less than than the compileSdkVersion, it's not uncommon to see a well-maintained/established app with targetSdkVersion > compileSdkVersion
The compileSdkVersion should be newest stable version.
The targetSdkVersion should be fully tested and less or equal to compileSdkVersion.
The CompileSdkVersion is the version of the SDK platform your app works with for compilation, etc DURING the development process (you should always use the latest) This is shipped with the API version you are using
You will see this in your build.gradle file:
targetSdkVersion: contains the info your app ships with AFTER the development process to the app store that allows it to TARGET the SPECIFIED version of the Android platform. Depending on the functionality of your app, it can target API versions lower than the current.For instance, you can target API 18 even if the current version is 23.
Take a good look at this official Google page.
I see a lot of differences about compiledSdkVersion in previous answers, so I'll try to clarify a bit here, following android's web page.
A - What Android says
According https://developer.android.com/guide/topics/manifest/uses-sdk-element.html:
Selecting a platform version and API Level When you are developing
your application, you will need to choose the platform version against
which you will compile the application. In general, you should compile
your application against the lowest possible version of the platform
that your application can support.
So, this would be the right order according to Android:
compiledSdkVersion = minSdkVersion <= targetSdkVersion
B - What others also say
Some people prefer to always use the highest compiledSkdVersion available. It is because they will rely on code hints to check if they are using newer API features than minSdkVersion, thus either changing the code to not use them or checking the user API version at runtime to conditionally use them with fallbacks for older API versions.
Hints about deprecated uses would also appear in code, letting you know that something is deprecated in newer API levels, so you can react accordingly if you wish.
So, this would be the right order according to others:
minSdkVersion <= targetSdkVersion <= compiledSdkVersion (highest possible)
What to do?
It depends on you and your app.
If you plan to offer different API features according to the API level of the user at runtime, use option B. You'll get hints about the features you use while coding. Just make sure you never use newer API features than minSdkVersion without checking user API level at runtime, otherwise your app will crash. This approach also has the benefit of learning what's new and what's old while coding.
If you already know what's new or old and you are developing a one time app that for sure will never be updated, or you are sure you are not going to offer new API features conditionally, then use option A. You won't get bothered with deprecated hints and you will never be able to use newer API features even if you're tempted to do it.
My 2 cents: Compile against any version of the SDK but take care not to call any APIs that your "minimum SDK version" does not support. That means you "could" compile against the latest version of the SDK.
As for "target version" it simply refers to what you planned to target in the first place and have possibly tested against. If you haven't done the due diligence then this is the way to inform Android that it needs to perform some additional checks before it deploys your lets say "Lollipop" targeted app on "Oreo".
So the "target version" is obviously not lower than your "minimum SDK version" but it can't be higher than your "compiled version".
Not answering to your direct questions, since there are already a lot of detailed answers, but it's worth mentioning, that to the contrary of Android documentation, Android Studio is suggesting to use the same version for compileSDKVersion and targetSDKVersion.
compiledSdkVersion==> which version of SDK should compile your code to bytecode(it uses in development environment) point: it's better use last version of SDK.
minSdkVersion==> these item uses for installation of APK(it uses in production environment). For example:
if(client-sdk-version < min-sdk-versoin )
client-can-not-install-apk;
else
client-can-install-apk;
Quick summary:
For minSDKversion, see latest entry in twitter handle: https://twitter.com/minSdkVersion
TargetSDKversion: see latest entry in twitter handle: https://twitter.com/targtSdkVersion
or use the latest API level as indicated at devel https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
Compiled version:
make it same as TargetSDKversion
maxSdkVersion:
advice from Android is to not set this as you do not want to limit your app to not perform on future android releases
The Application settings of an Android project's properties in Visual Studio 2017 (15.8.5) has them combined:
I have gone through the following links but they don't provide a clear and definitive answer to my question. This is what I could derive from the answers:
targetSdkVersion indicates that the app is tested against the target version and will run on all android versions from minSdkVersion to targetSdkVersion
with no compatibility issues.
Android Min SDK Version vs. Target SDK Version
what is the difference between "min sdk , target sdk and compile with " ? in android
My app's minSdkVersion=11 and targetSdkVersion=19, Now I am not sure whether devices with higher SDK versions will see my app on Google Play Store or not.
UPDATE: For those who may encounter this question here is a great article I found:
http://www.thedroidsonroids.com/blog/android/compile-min-max-and-target-sdk-versions/
As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect. You can disable such compatibility behaviors by specifying targetSdkVersion to match the API level of the platform on which it's running. For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher and also disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).
Android Developer, So the answer is yes, but you might want to consider testing and updating to current SDK version.
Yes, devices with higher SDK versions will see your app. Features of newer SDKs like granular permissions in Android 6.0 will not be available if they are not supported in your code.
The documentation for android:maxSdkVersion makes the situation clearer:
Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.
It works on SDK 11 and upwards, as in your first Link stated.
Yes. Your app will be visible to the devices with higher sdk versions than your targetSdkVersion.
By specifying targetSdkVersion you can restrict google by applying default compatibility behaviours.So that you will get along with the api level of the device in which your app is running.
Yes, newer devices will see it. Let's do a thought experiment. Let's go back in time one year. We build an app, setting the minSDKVersion and targetSdkVersion to X, the highest available number in the toolset. Six months ago, X+1 got released. And today I just bought a new phone that runs X+1, and I'm very excited! Wait, what? That brand new app isn't in the store? But it worked on my old phone!
That would be crazy. :)
As a more concrete example, here's an app that has minSdkVersion 15
targetSdkVersion 17: https://play.google.com/store/apps/details?id=com.nasarallysport.rallyracetimer I just verified that I can see it in google play with my Nexus 6 on api 23.
I have looked at the documentation for building with Gradle, but I'm still not sure what the difference between compileSdkVersion and targetSdkVersion is.
All it says is:
The `compileSdkVersion` property specifies the compilation target.
Well, what is the "compilation target"?
I see two possible ways to interpret this:
compileSdkVersion is the version of the compiler used in building the app, while targetSdkVersion is the "API level that the application targets". (If this were the case, I'd assume compileSdkVersion must be greater than or equal to the targetSdkVersion?
They mean the same thing. "compilation target" == "the API level that the application targets"
Something else?
I see that this question has been asked before, but the one answer just quotes the doc, which is what is unclear to me.
compileSdkVersion
The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.
targetSdkVersion
The targetSdkVersion has nothing to do with how your app is compiled or what APIs you can utilize. The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify. This is more like a certification or sign off you are giving the Android OS as a hint to how it should handle your app in terms of OS features.
For example, as the documentation states:
For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher...
The Android OS, at runtime, may change how your app is stylized or otherwise executed in the context of the OS based on this value. There are a few other known examples that are influenced by this value and that list is likely to only increase over time.
For all practical purposes, most apps are going to want to set targetSdkVersion to the latest released version of the API. This will ensure your app looks as good as possible on the most recent Android devices. If you do not specify the targetSdkVersion, it defaults to the minSdkVersion.
As a oneliner guide:
minSdkVersion <= targetSdkVersion <= compileSdkVersion
Ideally:
minSdkVersion (lowest possible) <= targetSdkVersion == compileSdkVersion (latest SDK)
Read more from this great post by Ian Lake
Late to the game.. and there are several great answers above-- essentially, that the compileSdkVersion is the version of the API the app is compiled against, while the targetSdkVersion indicates the version that the app was tested against.
I'd like to supplement those answers with the following notes:
That targetSdkVersion impacts the way in which permissions are requested:
If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the app requests permissions from the user at run-time.
If the device is running Android 5.1 (API level 22) or lower, or the app's targetSdkVersion is 22 or lower, the system asks the user to grant the permissions when the user installs the app.
If the compileSdkVersion is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect. (ref)
With each new Android release...
targetSdkVersion should be incremented to match the latest API level, then thoroughly test your application on the corresponding platform version
compileSdkVersion, on the other hand, does not need to be changed unless you're adding features exclusive to the new platform version
As a result, while targetSdkVersion is often (initially) less than than the compileSdkVersion, it's not uncommon to see a well-maintained/established app with targetSdkVersion > compileSdkVersion
The compileSdkVersion should be newest stable version.
The targetSdkVersion should be fully tested and less or equal to compileSdkVersion.
The CompileSdkVersion is the version of the SDK platform your app works with for compilation, etc DURING the development process (you should always use the latest) This is shipped with the API version you are using
You will see this in your build.gradle file:
targetSdkVersion: contains the info your app ships with AFTER the development process to the app store that allows it to TARGET the SPECIFIED version of the Android platform. Depending on the functionality of your app, it can target API versions lower than the current.For instance, you can target API 18 even if the current version is 23.
Take a good look at this official Google page.
I see a lot of differences about compiledSdkVersion in previous answers, so I'll try to clarify a bit here, following android's web page.
A - What Android says
According https://developer.android.com/guide/topics/manifest/uses-sdk-element.html:
Selecting a platform version and API Level When you are developing
your application, you will need to choose the platform version against
which you will compile the application. In general, you should compile
your application against the lowest possible version of the platform
that your application can support.
So, this would be the right order according to Android:
compiledSdkVersion = minSdkVersion <= targetSdkVersion
B - What others also say
Some people prefer to always use the highest compiledSkdVersion available. It is because they will rely on code hints to check if they are using newer API features than minSdkVersion, thus either changing the code to not use them or checking the user API version at runtime to conditionally use them with fallbacks for older API versions.
Hints about deprecated uses would also appear in code, letting you know that something is deprecated in newer API levels, so you can react accordingly if you wish.
So, this would be the right order according to others:
minSdkVersion <= targetSdkVersion <= compiledSdkVersion (highest possible)
What to do?
It depends on you and your app.
If you plan to offer different API features according to the API level of the user at runtime, use option B. You'll get hints about the features you use while coding. Just make sure you never use newer API features than minSdkVersion without checking user API level at runtime, otherwise your app will crash. This approach also has the benefit of learning what's new and what's old while coding.
If you already know what's new or old and you are developing a one time app that for sure will never be updated, or you are sure you are not going to offer new API features conditionally, then use option A. You won't get bothered with deprecated hints and you will never be able to use newer API features even if you're tempted to do it.
My 2 cents: Compile against any version of the SDK but take care not to call any APIs that your "minimum SDK version" does not support. That means you "could" compile against the latest version of the SDK.
As for "target version" it simply refers to what you planned to target in the first place and have possibly tested against. If you haven't done the due diligence then this is the way to inform Android that it needs to perform some additional checks before it deploys your lets say "Lollipop" targeted app on "Oreo".
So the "target version" is obviously not lower than your "minimum SDK version" but it can't be higher than your "compiled version".
Not answering to your direct questions, since there are already a lot of detailed answers, but it's worth mentioning, that to the contrary of Android documentation, Android Studio is suggesting to use the same version for compileSDKVersion and targetSDKVersion.
compiledSdkVersion==> which version of SDK should compile your code to bytecode(it uses in development environment) point: it's better use last version of SDK.
minSdkVersion==> these item uses for installation of APK(it uses in production environment). For example:
if(client-sdk-version < min-sdk-versoin )
client-can-not-install-apk;
else
client-can-install-apk;
Quick summary:
For minSDKversion, see latest entry in twitter handle: https://twitter.com/minSdkVersion
TargetSDKversion: see latest entry in twitter handle: https://twitter.com/targtSdkVersion
or use the latest API level as indicated at devel https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
Compiled version:
make it same as TargetSDKversion
maxSdkVersion:
advice from Android is to not set this as you do not want to limit your app to not perform on future android releases
The Application settings of an Android project's properties in Visual Studio 2017 (15.8.5) has them combined:
The more I read about this, the more I get confused. It seems easy while reading, but few seconds later, it just bounces over my head. Anyway, here is my question.
I have a published app, and I wish to add admob advertising to it. As far as I read, i need to have the targetSDKVersion in my manifest file, to be 13 or higher. When i set the targetSDKVersion to 13, eclipse shows me a warning saying,
"Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
Well, as of now, this is my understanding of minSDKVersion and targetSDKVersion.
minSDKVersion = this is for backward compatability. I have my minSDKVersion set to 10, for Android 2.3.3, which is the version i developed my application. So, people with a minimum of Android version of 2.3.3 will be able to use my application.
targetSDKVersion = this is to tell that I have used a feature in my application, that belonged to the targetSDKVersion and people with versions equal to and above will get to see that feature, where as people with lower versions, will be able to use the application, but doesn't get to see the feature.
So, if my understanding is correct, what about the warning? What does this warning mean?
And also, admob states that it requires a minimum of Android 1.5 or later. But the documentation says, compile against Android version 3.2. What about this?
I am pretty new to android as well as admob, so please bear with me, if these are pretty basic questions.
Thanks!!!
You are getting that warning as targetSdkVersion is used to tell 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. And now the targetSdkVersion version is 16 but you are setting it in 13 so it shows that warning.
If you change it to 16 then or 17 then you will not get that warning.
android:targetSdkVersion="16"
You can learn more from here application's compatibility