What should be the Target SDK when publishing an Android app? - android

I have been working on an Android project from past one year in Eclipse with API level set to 4.2 (target SDK 17).
Now I want to publish it in the Play Store. Should I change the target SDK (manifest file) to the latest (i.e. 4.4) since my app works perfectly on KitKat?

The purpose of targetSdkVersion is explained in the developer documentation for <uses-sdk>:
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).
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.
TL;DR: You should set targetSdkVersion to the API level that you've primarily been developing and testing on. Google recommends that you see to it that this is the latest Android version, but that may not always be feasible (for financial and other reasons).

See your app will work fine with kitkat because the newer versions are always made to be compatible with the older android versions,but vice versa is not true....if you develop something in higher API level and then try to run it in older versions of android, than it may happen that your app may not work or some features may not work as expected.So,you too can add KITKAT compatibility in your android manifest file ...cheers

As per this announcement you have to make sure to use a recent target SDK (at most one or two versions older than the most recent), otherwise you cannot publish your app in the Play Store. This is enforced for new apps as of August 2018 and November 2018 for updating existing apps, requiring you to target API level 26 or newer.

Related

Instant App, What's the actual minimum sdk

As per the android developers site, minimum sdk for Instant app is 21, ie 5.0.
link
The site clearly states : Android Instant Apps are available on the majority of devices running Android 5.0 (API level 21) and higher.
But when we create a new project as per the guideline given in this link
which states that we need to have minimum sdk of 23, to get instant app support.
And does not allow me to create a support for 5.0.
as shown in below image which I tried :
That requirement exists only in the setup wizard, and it is a bug. If you change the value to something lower after creating the project, you'll see that it builds fine and can run on API 21 and 22 devices.
The documentation is correct about supported Android versions, but note that even that doesn't dictate any particular minSdkVersion. You can build an instant app with a minSdkVersion lower than 21. It just won't run on anything before 21, since the Instant Apps Runtime itself is restricted to 21+.
For that reason, this check was always a bug, even when we didn't support devices before 23. I was told it was fixed in 3.0, though I didn't verify. I checked tonight and confirmed that the check is still present in 3.0. Could be fixed in a more recent version. But if not, we need to fix that. I'll follow up.
That requirement might be due to android run-time permission support Requesting Permissions at Run Time as official document mention
Note: Beginning with Android 6.0 (API level 23), users can revoke permissions from any app at any time, even if the app targets a lower API level. You should test your app to verify that it behaves properly when it's missing a needed permission, regardless of what API level your app targets.
Currently it has been fixed with android studio 3.1 Canary 5
For instance app minimum API 23: Android 6.0 (Marshmallow).
Please follow this link https://developer.android.com/topic/instant-apps/getting-started/first-instant-app.html

Will my application be visible to devices higher than my targetSdkVersion in Google Play Store?

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.

SDK level problems in developer console

so im working on a small utility app to get started on the play store and ive come across a few issues which has led me up to this
It is forbidden to downgrade devices which previously used M permissions (target SDK 23 and above) to APKs which use old style permissions (target SDK 22 and below). This occurs in the change from version 1 (target SDK 23) to version 2 (target SDK 19).
for a small app like this it would be irritating for it to only be available on newer versions considering it doesnt require much. I cant remove the apk nor can i delete the project entirely so the question is should i just publish it for sdk 23 or should i just leave the project alone and make an entirely new one?
You are mistaken. Target SDK means the latest supported version. But it would still allow applications be installed on newer versions. Min SDK version means the earliest supported version.
If Target SDK is set to 23, and update comes out, which is 24, then app would still work on that device, however, whatever new features SDK 24 brings, won't be available.
You can read more at API Guides

I want update the Application on playstore with changed targetSdkVersion

I have already updated an app to playstore with below-mentioned uses-SDK:
<uses-sdk
android:maxSdkVersion="23"
android:minSdkVersion="17"
android:targetSdkVersion="23"/>
I want to downgrade my targetSdkVersion "23" to "22". I've done it. if I upload to playstore, will the update work for all the users properly?
You won't have any problem at all. What you are saying with your <uses-sdk> is that your app is fully tested to run in version 22 and can even run in lower versions until 17.
I suggest you to take a look to this documentation ver carefully.
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).
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).
There are many compatibility behaviors that the system may enable
based on the value you set for this attribute. Several of these
behaviors are described by the corresponding platform versions in the
Build.VERSION_CODES reference.
To maintain your application along with each Android release, you
should increase the value of this attribute to match the latest API
level, then thoroughly test your application on the corresponding
platform version.
NO. You'll not be able to update your app by changing target SDK from
23 to 22.
PROBLEM
Users that have the APK with version code 6, which targets SDK 23 or higher, will receive an error when they attempt to upgrade to this APK because it targets SDK 22.
Now, as you all know, when we keep target SDK to <23, while installing the app by default all the permissions are granted for the app and if we keep target SDK 23 or higher, all the permissions are set to OFF while installing the app.
RESOLUTION
Ensure that your release including APKs targeting SDK 23 or higher to which all users that have the APK with version code 6 can upgrade.
If you didn't change the code(except the gradle file) and the app still works on the '23' version emulator then there shouldn't be any problem.
It really depends on which features(classes and methods) you used in your code.
If you didn't use any of Android 6's features in your code, then there shouldn't be any problem downgrading the target sdk version without having any change for android 6 users.

What factors are important in choosing target android OS for development

What do I need to consider before choosing the target android OS for app development?
This is my understanding of how to do it and any clarification would be appreciated:
Determine which OS version is currently in use the most. Look at distribution graphs etc.
Target that version.
that is what I read all the time, but I have some questions.
Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are unique to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.? Consider the reverse situation. If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?
thanks.
have a look at your AndroidManifest.xml
There is a targetSdkVersion and minSdkVersion if you want to support all devices running 2.2 and up then set minSdkVersion to api level 8 (android 2.2)
but in general, its a good practice to develop against the latest api as target (currently API 19, Android 4.4), so you can ensure it will work from your chosen min up to the newest OS api
so if you want to support at least Gingerbread up to KitKat do this in your manifest:
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19" />
and develop against api 19 :)
Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are new to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.?
Only if you don't use APIs that were introduced after the earliest version you want the app to run on.
If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?
Yes. Some functions get deprecated in newer OS versions, but most of them still work in newer releases for keeping compatibility.
I feel the thing to stress here is that Android is backwards compatible, so newer versions will almost be able to run apps developed for older OS versions.
The target version is the highest version you have tested it on. You should always target the absolute latest if you can. The min version is the lowest version that will be able to install the app.
So in the manifest, you would typically have something like this:
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" ...
Pick the minSdkVersion based on the features that are absolutely required for your app to function.
So you might wonder what the purpose of targetSdkVersion is. One reason is if your app has some optional features that are in later versions of the SDK. targetSdkVersion will allow you to use those later features, but you will need to protect those method calls with a check against the device's SDK with a call like
if (Build.VERSION.SDK_INT >= 11)
myMethodThatUsesFeaturesOnlyInHoneycombAndLater();
Another reason is that sometimes the Android team makes changes to some of the defaults in various settings on your classes, but to maintain compatibility for future versions on which you have not tested your app, they keep the old default if your app doesn't claim to target this later version.
For example, after Honeycomb, the menu is supposed to be integrated with the action bar. But old apps that were compiled with earlier SDKs have not been tested with Honeycomb or later, as proved by them having a targetSdkVersion of less than 11, so the OS knows to display the old style menu. Once this developer decides to test their app on a more recent targetSdkVersion, they update the value and the OS can trust that they have tested it on Honeycomb, so it can safely show the new style menu.

Categories

Resources