0

Hi everyone I am new to android developing.I download the latest version of android studio 1.3.2 yesterday.But when I start a new project for testing, gradle give me an error. My gradle is

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.example.niyamat.testing3"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

      dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.+'

}

The error is

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]   C:\Users\Niyamat\Documents\Testing3\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0-rc1\AndroidManifest.xml

I know there are some question about the same error but I didn't find any good solution. So please someone help me?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Niyamat Ullah
  • 2,384
  • 1
  • 16
  • 26

4 Answers4

1

Whats your Logcat Throws

 Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

What should you Do

  1. Remove minSdkVersion version from Manifest .You already declare it in your build.gradle .
  2. Use this compileSdkVersion 21 buildToolsVersion '21.1.2' instead yours.
  3. Compile compile 'com.android.support:appcompat-v7:21.0.1'

First of all remove this line from your Manifest .

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />

Finally

    apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.niyamat.testing3"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

      dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.1'

}
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

Seems you have a previous version of the app compat into your lib folder specific for android L.

Also you should set the version for compileSdkVersion, buildToolVersion, targetSdkVersion and the appcompat-v7 to be the same.

In your case, the buildToolVersion should be "21.1.2".

xiaomi
  • 6,553
  • 3
  • 29
  • 34
0

Basically, this is the reason why android studio complains / suggests NOT using .+ in your compiles.

compile 'com.android.support:appcompat-v7:21.+'

It forces compile with absolute last version of appcompat 21 which is com.android.support:appcompat-v7:21.0.0-rc1 (as you can see from error you got). That version does not allow minSdkVersion 15 - it's made for Lollipop. Change your compile appcompat to version number that does allow minSdkVersion 15 to solve the issue.

poss
  • 1,759
  • 1
  • 12
  • 27
0

It is your issue.

uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

It is quite strange that you have in your sdk folder the preview version of appcompat 21. This version was published with the lollipop preview (api-L) and had the minSdk = L. It is the reason of your issue (because you have minSdkVersion 15)

You should not have this folder in your sdk. Check with the SDK Manager if it is updated.

Then you can modify your build.gradle removing the +.

Support libraries v21

compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.3'

Support libraries v22 (require compileSdkVersion 22)

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.1'

Support libraries v23 (require compileSdkVersion 23)

compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Thank you Gabriele Mariotti.I first don't understand your answer but after a few time later I understand that compile sdkversion should match the support library version.Then I do it and my gradle sync successfully. – Niyamat Ullah Sep 08 '15 at 12:58