21

I'm studying this Building Simple Chat Client with Parse and I'm using gradle 2.4 to build my project. My build.gradle and AndroidManifest.xml codes are:

build.gradle

 buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
    }
 }

 apply plugin: 'com.android.application'

 android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
 }


 repositories {
    jcenter()
 }


 dependencies {
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile 'com.parse.bolts:bolts-android:1.+'
 }

 dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.android.support:appcompat-v7:21.0.0+'    
    compile 'com.squareup.picasso:picasso:2.5.0'
 }

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application android:label="@string/app_name" 
android:name="main.java.org.hello.ChatApplication">
    <activity
        android:name=".ChatActivity"
        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>

I'm getting the next error:

/home/grados-sanchez/workspace/simplechat/src/main/AndroidManifest.xml:0:0   Error:
uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in    library /home/grados-sanchez/workspace/simplechat/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller   than version 7 declared in library /home/grados-sanchez/workspace/simplechat/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/AndroidManifest.xml
  Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --    debug option to get more log output.

BUILD FAILED

Could you help me please

3 Answers 3

35

You have to add the minSdkVersion to your build.gradle.

Otherwise, gradle uses the default value = 1.
You are using a library with minSdk=7, then you can't use minSdk=1.

Also pay attention that gradle overrides the values in the Manifest.

Add something like this:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14  
        targetSdkVersion 22
    }
}

Pay attention to your build.gradle. You have two dependencies blocks. You have to merge these blocks.

4
  • thanks by your reply, but when I addd something as your code. Now I get UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/parse/FacebookAuthenticationProvider$1; at .... :dexDebug FAILED
    – Juan
    Commented May 13, 2015 at 9:47
  • @Juan it is another problem. My answer should resolve the question you posted. The UNEXPECTED TOP-LEVEL EXCEPTION means that you are using twice the same library. Check your jar files. Commented May 13, 2015 at 11:22
  • Wow, True way to solve this. Thank you. :) i was having two modules. Inside seconds modules build.gradle defaultConfig was missing. Commented Jun 16, 2016 at 7:44
  • Worked fine. Thank you
    – Br3x
    Commented Jan 25, 2018 at 17:31
7

Just add

<uses-sdk tools:overrideLibrary="android.support.v7.appcompat"/>

to your AndroidManifest.xml and it will work. This will enable the Manifest merger to add this also when the API version is older. Don't forget to add the tools namespace at your xml root as shown below.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.app"
      xmlns:tools="http://schemas.android.com/tools">

You can also find more information about this here.

2
  • when I add that line into my AndroidManifest.xml I get :21:65: The prefix "tools" of attribute "tools:overrideLibrary" asociated a kind of element "uses-sdk" is not vinculated.
    – Juan
    Commented May 13, 2015 at 9:50
  • Did you add xmlns:tools="http://schemas.android.com/tools" to your Manifest root element?
    – and_dev
    Commented May 18, 2015 at 9:45
3

It seem that you have forget to add the following code in build.gradle. add it into build.gradle and try to compile

 defaultConfig {
    applicationId "com.XXX.XXXX"  // your application package 
    multiDexEnabled true
    minSdkVersion 14
    targetSdkVersion 18
    versionCode 99
    versionName "11.1.5.5"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.