I'm very confused with gradle versioning settings. I found some information about this build system, but nowhere was written about versioning details. Can you explain what these options mean?
compileSdkVersion
buildToolsVersion
minSdkVersion
targetSdkVersion
The minSdkVersion is most obvious, because it means the minimal API we want to support, e.g. 14 (Android >= 4.0).
The targetSdkVersion:
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.
I don't quite understand that.
My case is to support devices from API 15. What are the proper settings for that?
I read somewhere that target should be the highest as possible, Android Studio tells me that too, but when I set this up and try to run on Nexus 5 I get:
Failure [INSTALL_FAILED_OLDER_SDK]
My build.gradle
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "my.package.name"
minSdkVersion 14
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
According to official doc:
http://developer.android.com/preview/setup-sdk.html#createProject
if you would like to try out new features you should use these values:
compileSdkVersion is set to 'android-L'
minSdkVersion is set to 'L'
targetSdkVersion is set to 'L'
It is the reason of Failure [INSTALL_FAILED_OLDER_SDK].
If you don't need android-L I suggest using these values:
defaultConfig {
applicationId "my.package.name"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
Said that, there is an unofficial workaround described here (in any case I suggest that you don't use it)
Failure [INSTALL_FAILED_OLDER_SDK] Android-L
Related
what are the best apk level to run a app in a android lollipop 5.1 version. Here is what I currently having
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.locationtracker2019"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
As per your Question your application is running in the minSdkVersion means that your minimum version support your app.
targetSdkVersion is the main way Android provide forward compatibility not applying behavior change unless the targetSdkVersion is update.
It should be emphasized that changing your compileSdkVersion does not change runtime behavior. While new compiler errors/warnings may present when chang your compileSdkVersion, your compileSdkVersion is not included in your APK: it is purely used at compile time.
For more information about, What is API Level?
I hope it'll help you...!
I'm using latest dependencies in my project. My minSdkVersion is set as 15 and targetSdkVersion is 26. Which build tools and compileSdkVersion should I use so that the app can be run even in Adnroid 5.
Here are the details-
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.app.shoppingbull"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
Will these work fine in all devices or I have to reduce the CompileSdkVersion?
Always follow this,
minSdkVersion <= targetSdkVersion <= compileSdkVersion
Because, when you develop app always target the latest SDK so that you provide the latest features of Google to your user.
According to source.android.com if you want to make your App can be run in Adnroid 5 and newer, you should set the minSdkVersion to 21
tip: don't make your minSdkVersion lower than 21
Your application will work in the range of minSdkVersion and targetSdkVersion api level.
You should target your app to the latest version of Android SDK version (see SDK Platform release notes) to make sure you've covered all the Android version. It also force you to check if your code is working correctly with the latest version.
So, change your app build.gradle to something like this:
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.app.shoppingbull"
minSdkVersion 15
targetSdkVersion 28 // latest stdk
versionCode 1
versionName "1.0"
Ideally, your targetSdkVersion and compileSdkVersion should be the same, and the latest. That's 28 at the current time of writing.
minSdkVersion dictates the minimum version your app will support, so having a compile/target of 28 will still let you run on 15.
I'm trying to refactor my code to androidX. To do so android asked me to update the compiled version to at lease 28. So I changed my compiled version to compileSdkVersion 28 in bulid.gradle.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
But once I sync project I'm unable to download the platform plugins and the following error shows up in build window.
Failed to find target with hash string 'android-28' in: /Users/work/Library/Android/sdk
Your compile version should be android-p. They're using the version name now.
compileSdkVersion 'android-P'
And target should be just P
targetSdkVersion 'P'
See here to know how to set up Android P SDK.
Edit:
If your getting an error/warning "minSdkVersion (21) is greater than targetSdkVersion (1)" this is done on purpose, see here.
As Android P is still Preview, the 'P' in the targetSdkVersion will work as a version 1. Once it's out of preview it will be replaced with the usual 28. For now, to fix this you'd need to raise the minSdkVersion to also 'P'.
i released a old version
using this configs:
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "my.application.id"
minSdkVersion 15
targetSdkVersion 23
versionCode 3412
versionName "3.3.0"
multiDexEnabled true
}
and all dependencies using 23.4.0
after a i updated to
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "my.application.id"
minSdkVersion 15
targetSdkVersion 25
versionCode 3415
versionName "3.4.2"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
a special device is not compatible with the app anymore thru the Play Store
but the strange thing is, i can run the .apk from internal memory, and its installed perfectly!
i must allow this device to download from PlayStore, since most of my users use this special tablet, i dont know what is wrong cuz there is no error, no output, the APP works in this device, but for play store, its incompatible
im using the new Rollout system and testing thru beta/alpha not working for this app too
the problem was a library using the required flag for camera at the manifest.
for someone having something similiar, look at the dependencies
I am new to Android Studio and made an app but its not running on my physical device HTC one M8 giving and error like Failure [INSTALL_FAILED_OLDER_SDK]
htc one m8
android version: 5.0.2
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.darab.crazy_tip_calc"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Your device OS version is lower than you're app SDK version.
minSdkVersion 22
targetSdkVersion 22
Check your device version. I would suggest to set minSdkVersion to 15 or the the API level of your device. And this is 21 (5.0.2 of your M8).
Just set minSdkVersion 15 instead of 22
android:minSdkVersion
An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.darab.crazy_tip_calc"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Check your minSdk version and Target Sdk Version.