Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Build an Android project with Android library which depends on another Android Library

I need to build using Gradle an Android project which depends on an Android Library project A, which depends on another Android Library project B.

So far I have the following:

Android project:

build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

apply plugin: 'android'

dependencies {
    compile project(':LibA')
}

android {
    compileSdkVersion 7
    buildToolsVersion "17.0.0"
}

manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cyborg.template"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.cyborg.template.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>

Android Library A:

build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android-library'

dependencies {
    compile project(':LibB')
}


android {
    compileSdkVersion 7
    buildToolsVersion "17.0.0"
} 

manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.lib.project.a"
          android:versionCode="1"
          android:versionName="1.0">

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

</manifest>

Android Library B:

build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android-library'

android {
    compileSdkVersion 7
    buildToolsVersion "17.0.0"
} 

manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.lib.project.b"
          android:versionCode="1"
          android:versionName="1.0">

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

</manifest>

While trying to build the Android project, the following error is reported from Android studio:

Gradle: Execution failed for task ':LibA:processDebugManifest'.
  > Manifest merging failed. See console for more info.

Where is that console am I suppose to search for more info about the error?

I've found some questions regarding this error, but it does not seem to be the same case as mine.

Enlightenments?

Thanks, Adam.

like image 718
TacB0sS Avatar asked Jul 19 '13 21:07

TacB0sS


1 Answers

The manifest files for the library must currently have a <application /> node, even if it's empty.

It's a restriction we'll remove at some point but for now, just add it.

like image 103
Xavier Ducrohet Avatar answered Sep 27 '22 19:09

Xavier Ducrohet