3

The following error is produced when building my app

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library C:\Users\Sybren-PC\AndroidStudioProjects\Tutorial\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0-rc1\AndroidManifest.xml

I tried some things in the build.gradle but nothing seems to work.

The error message points to this file

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright (C) 2012 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="android.support.v7.appcompat" >

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

    <application />

</manifest>

AndroidManifest.xml (from my project)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.sybren_pc.tutorial" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.sybren_pc.tutorial"
        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.+'

}

Anyone who can help to fix this?

EDIT

This is how my build.gradle looks now. The gradle build is okay now.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.sybren_pc.tutorial"
        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.0'

Updates I did from the SDK Manager : Android SDK Build Tools, Android Support Repository, Android Support Libary

Community
  • 1
  • 1
Sybren
  • 1,071
  • 3
  • 17
  • 51

1 Answers1

1

First thing, you declared in Manifest.xml

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

You may remove those lines at all, because Gradle overrides Manifest's values, so you may specify versions only in Gradle (Source).

And the error happened because compileSdkVersion in build.gradle is lower than declared in Manifest.xml - it complains about that.

Second thing is: In build.gradle you use buildToolsVersion = 20.0.0, but you want to compile it for SDK Version = 21. It cannot. You should update BuildTools via SDK Manager. Here is a doc about latest Build Tools and also nice article to take a look. Nice explanation there.

I hope this solve your problem. Cheers.

Community
  • 1
  • 1
Yurets
  • 3,999
  • 17
  • 54
  • 74
  • I didn't declare anything in the first Manifest.xml it's just where the error message points to. I upgraded the `buildToolsVersion` , and what do you mean by : `compileSdkVersion in build.gradle is lower than declared in Manifest.xml` how to solve that? – Sybren May 02 '15 at 17:52
  • You may remove `` from `Manifest` at all, another way, they must be same in both files. So change values in manifest to match them with `gradle`. If you updated `build tools` to 22.0.0 version, so you should set `minSdkVersion` = 15 (as same as in `build.gradle`) and `compileSdkVersion` can be 22 already. `targetSdkVersion` could be whatever, but also same (I mean from 15 until 22). – Yurets May 02 '15 at 17:57
  • I solved it! Look at my opening post for my solution. – Sybren May 02 '15 at 18:05
  • Yes, that's right, `buildSdkTools` cannot be lower than `compileSdkVersion`. Glad it solved. Cheers :) – Yurets May 02 '15 at 18:07