2

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'
        }
    }
}
Kamil Lelonek
  • 14,592
  • 14
  • 66
  • 90

1 Answers1

2

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

Community
  • 1
  • 1
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I can't use `minSdkVersion is set to 'L'`, because I'm targeting to Android 14. – Kamil Lelonek Jul 27 '14 at 12:09
  • Android-L is a preview.Google decided it to prevent app in google play using this beta APIs. The only way is to follow the workaround above. Otherwise you have to use different flavours and when it will become official, you can merge it. – Gabriele Mariotti Jul 27 '14 at 14:13
  • I decided to build agains 19 version. – Kamil Lelonek Jul 27 '14 at 14:14
  • 2
    This isn't good advice for someone who wants to target API 14. You should only use the L SDK if you want to try out features for the future L release. If you don't need L, then it's best to use a non-prerelease version of the SDK and avoid messing around with it to get your APKs to run on non-L devices. – Scott Barta Jul 28 '14 at 16:28
  • @ScottBarta You are right. I've edited my question to explain better. – Gabriele Mariotti Jul 28 '14 at 20:52