How set the android max sdk version on build.gradle at android studio.
I want do an app with two flavor, the first will run between version x~y and the second run at y+
Before on eclipse, in AndroidManifest.xml we have android:maxSdkVersion="y" but how it works on gradle?
You cannot set the maxSdkVersion in gradle. Actually, it is discourage by Google because of several issues. The main issue is that Google Play could decide to remove an app from a user device during an update if the system doesn't meet the maxSdkVersion specified in the app. For example, imagine you have a device with API Level 12 and you install an app with android:maxSdkVersion="12", then later you receive a system update that upgrades your android version to API Level 13...Google Play will uninstall your app.
Basically, you don't need this setting and you can easily ignore it, use the targetSDkVersion attribute and the minSdkVersion.
For your app "in flavour 1" with "version x~y" set the minSdkversion to x and the targetSdkVersion to y
now, for the app "in flavour 2", you will need to make sure that the sdk version don't get overlapped by the app "in flavour 1", set the min sdk version to "z". Otherwise, users with a device with api level "y" will never get to see this app in Google Play
Please note this.
Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation. Google Play will continue to use the attribute as a filter, however, when presenting users with applications available for download.
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
I think accepted answer is not correct. Accepted answer says it is not possible to set maxSdkVersion - it is not true. It is still possible to use maxSdkVersion in android studio app/build.gradle. As described here https://developer.android.com/guide/topics/manifest/uses-sdk-element developer must notice warning and should understand why wants to do it. Nobody here take care that in play store you can provide several bundles/packages at once (per update/release) and one bundle can be targeted for new devices and another for old devices so it is fine second one limit by maxSdkVersion. One app bundle have versionCode e.g. 2xyz and for older devices is versionCode 1xyz and google always installs higher code when minSdkVersion allows it. So developer can purposely set maxSdkVersion and he know why hi is doing it.
Each our app update have 2 packages with different app/build.gradle...
For old devices
(maxSdkVersion has sense here)
defaultConfig {
minSdkVersion 16
maxSdkVersion 23
targetSdkVersion 30
versionCode 1058
versionName "4.4.0"
}
For new devices
(without limiting maxSdkVersion as googole warns that should not be used)
defaultConfig {
minSdkVersion 24
targetSdkVersion 30
versionCode 2058
versionName "4.4.0"
}
Related
If my App has minSDKVersion = 16 and TargetSDKVersion = 28, then will Google somehow upgrade my App to work with devices which use sdk version greater than 28?
And if the same is true for all future versions of SDK then if I dont update my app meanwhile?
Please excuse me as my English is not good. Thanks.
Google never ever updates your apps for the latest SDK, you have to do it yourself and publish again. I know its a pain when google play console frequently changes requirements to support certain Target API Level but its the pain you have to endure. TargetSDKVersion is the last SDK / API which your app will support.
No, you will need to do an update by changing your targetSDK from your build.gradle file, then make the required changes in your code to work with that API level and you can upload an update.
The Playstore will not update it automatically, that's why it's called targetSDKVersion, it will just be available from SDK 16 until the target one, 28.
I have an app on the play store that that I am receiving crash reports from and have noticed that there are some crashes that are specific to an android version ( 4.0 - 4.4 ). I want to send out an update to only those android versions. How do I go about doing that because the play store doesn't give me any such option. The minimum api version I am targeting is 16 with a targetSDK version of 27. Do i need to change those values and make a target sdk version of 19 instead and push out the update? If so will it affect the availability of the app to devices with a higher api level?
This can be done in the Play store with a Multiple APK configuration.
Suppose the current version of your app has versionCode 100. You produce a new version with versionCode 101, which has:
minSdkVersion 14 (ICS, version 4.0)
maxSdkVersion 19 (KitKat, version 4.4)
You then create a release which has both version code 101 and version code 100 in it.
To make things slightly more complicated, you should think about a user who has a KitKat phone and upgrades their Android version. They would then be matched with version 100, but this would be a downgrade from versionCode 101 to versionCode 100, and downgrades are not allowed. So you should also produce a version 102 which is exactly the same as 100.
Because this is so complicated, it might be easier to just deliver the update to everyone, and keep a single APK.
When I try to upload the apk to store I get these warnings
Partially upgradable APK
WARNING
Some users of this APK may not be able to upgrade to any of the new APKs added in this release.
CAUTION
Users that currently have APK with version code 53, which targets SDK 22 or lower, will be eligible to upgrade to this APK. However, once users upgrade to this APK, they will be unable to upgrade to APKs that target SDK 22 or lower.
Following datas are my current build details
compileSdkVersion 26
buildToolsVersion 26.0.2
minSdkVersion 15
targetSdkVersion 26
This is my previous update details
compileSdkVersion 25
buildToolsVersion "25.0.3"
minSdkVersion 15
targetSdkVersion 22
This warning is because yoy have upgraded your api higher than 22 that means you have to handle some runtime permisions. The warning says that this is a one way switch i.e there is no way of coming back to targeting API 22 or earlier once you make the switch to the runtime permission model.The developer console is just confirming that you have done all the thing need for runtime permissions so no need to worry.
It is normal but in your case - you need to be careful since you target several levels higher.
Warning: Users using previous build would not be able to install the
update simply because of difference in permission models and higher
compile - 26. So if you don't make sure that you handle new permission
models and other functionalities, you may tend to lose part of your
users.
Caution: Users once they update to the new build will not be
able to upgrade back to lesser build of the same App. This means once
you publish your App in higher build successfully, you can't go back
to lesser build targets in your next update. Make sure all your
functionalities work in the new build before deploying.
Thanks
Its simply ok.
Warning indicates that once you increase your target version higher than your previous target version then users get update to newer targeted version app. But then after they cant receive update for lower target version.
But make sure you have handled Runtime Permission Model Properly for all dangerous group permission.
Rather than it does not affect your user base or nor your app functionality.
Happy Coding..
I read that if we want to update an app in google play, the version Code should be higher than the previous apk file. I've an app with version code: 20 and version name 1.0. So to update the app, how should I increase the version code? Should it increase by 10? or just 1 is enough? ie, version code from 20 to 30 or version code from 20 to 21?
VersionCode
This number is used only to determine whether one version is more
recent than another, with higher numbers indicating more recent
versions. Typically, you would release the first version of your app
with versionCode set to 1, then monotonically increase the value with
each release, regardless whether the release constitutes a major or
minor release. This means that the versionCode value does not
necessarily have a strong resemblance to the app release version that
is visible to the user (see versionName, below). Apps and publishing
services should not display this version value to users.
defaultConfig
{
minSdkVersion 17
targetSdkVersion 23
versionCode 1 // Default , You can increase 1 when update .
versionName "1.0"
}
You can use the Play Core Library In-app updates to tackle this. You can check for update availability and install them if available seamlessly.
In-app updates are not compatible with apps that use APK expansion files (.obb files). You can either go for flexible downloads or immediate updates which Google Play takes care of downloading and installing the update for you.
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...
}
Note that, In-app updates works only with devices running Android 5.0 (API level 21) or higher, and requires you to use Play Core library 1.5.0 or higher.
'
I hope this will help somebody
I increased it from code 1 and version 1.0 to code 2 and version 1.1 . That's also what it says in my developer console. So just do as you wish
Basically, For update your apk you should update version code to 21(just 1 increase) and your version name.
In android gradle build file I have the following closure:
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.mycoolapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 41
versionName "3.0"
}
}
I do not want my app to run on Marshmallow. My targetSdkVersion is 21 and Marmallow would be 23. So imagine I have a phone that is Marshmallow, if I go to the play store will my app appear in the listing?
My second question is how would I stop my app from appearing in google play store for marshmallow devices?
So imagine i have a phone that is Marshmallow, if i go to the play store will my app appear in the listing ?
Yes.
how would i stop my app from appearing in google play store for marshmallow devices?
You are welcome to try android:maxSdkVersion in the <uses-sdk> element of your manifest, as the current documentation suggests that the Play Store uses it as a filter, though this comes at a cost to users who get upgrades of their app to Android 6.0.
Answering not to original question, but to reasons of it.
I'm not sure you have to do it.
api 23 is asking for runtime permissions. so if i have a device running 23 and since android is backward compatible, what will happen for example if im using apache httpClient which is depreacated in marshmallow
You still can use HTTP client. From the docs:
To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
I tried to install my old applications which use HTTP Client on Android 6.0. They still work, without the dependency in build.gradle and even without recompiling.
or if im not prepared to handle runtime permissions ? wont my app break in this case ?
App wouldn't break. If you don't compile your app under Marshmallow (targetSdkVersion 23 or higher) then it will work in "legacy" mode: permissions will be requested before installation. With one exception: users still can switch off permissions in settings; I don't think that many users do it.
Try your app in emulator or real device. I'm almost sure it will work under Marshmallow.
may be i think it is described in app runtime permission model will work if we target api to 23
Note: This lesson describes how you implement permissions requests on apps that target API level 23 or higher, and are running on a device that's running Android 6.0 (API level 23) or higher. If the device or the app's targetSdkVersion is 22 or lower, the system prompts the user to grant all dangerous permissions when they install or update the app.
link: https://developer.android.com/intl/es/training/permissions/requesting.html
may be if i have some misunderstanding then please notify me