简体   繁体   English

Android Studio - 使用依赖于另一个Android库的Android库构建Android项目

[英]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. 我需要使用Gradle构建一个依赖于Android库项目A的Android项目,该项目取决于另一个Android库项目B.

So far I have the following: 到目前为止,我有以下内容:

Android project: Android项目:

build.gradle: 的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: 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: Android库A:

build.gradle: 的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: 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: Android库B:

build.gradle: 的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: 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: 在尝试构建Android项目时,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. 谢谢,亚当。

The manifest files for the library must currently have a <application /> node, even if it's empty. 库的清单文件当前必须具有<application />节点,即使它是空的。

It's a restriction we'll remove at some point but for now, just add it. 这是我们将在某些时候删除的限制,但现在,只需添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM