0

I'm trying to make an app using the android support library, so if I start a new project with a basic activity, then add the android support library using the dependencies menu, I get this error:

This support library should not use a different version (24) than the `compileSdkVersion` (23)

This is what my gradle file looks like:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.moore.criminalintent"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:24.0.0'
}

I've not touched any other settings apart from creating the project and adding the dependency. Any help in resolving this would be greatly appreciated.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
user2320239
  • 1,021
  • 2
  • 18
  • 43

3 Answers3

3

Since you are using the support libraries v24.

compile 'com.android.support:support-v4:24.0.0'

You have to compile with API 24. Use:

compileSdkVersion 24
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

Change compile 'com.android.support:support-v4:24.0.0' to compile 'com.android.support:support-v4:23+' (and optionally provide a sub version. The plus means the latest version of 23.something will be used).

This error is caused because you are compiling against API version 23 (android M), so you cannot use the support library version 24. Version 24 of the support library is for the recently released Android N developer preview, from my understanding.

Alternatively, you could of coarse increase your compile SDK version to 24.

Warrick
  • 1,623
  • 1
  • 17
  • 20
  • Hi, thanks for the answer, com.android.support:support-v4:23+ worked, however changing compileSdkVersion 23 to 24 give the error Error:Cause: failed to find target with hash string 'android-24'. Sorry I'm pretty new to this, I find it strange that the dependency wizard would import the wrong statement. – user2320239 Jun 23 '16 at 00:27
0

If your using compile SDK version 24 than you should use it as

compile 'com.android.support:support-v4:24.0.0'

sonal balekai
  • 395
  • 4
  • 10