【问题标题】:Building app with library module cannot find AndroidManifest.xml使用库模块构建应用程序找不到 AndroidManifest.xml
【发布时间】:2015-01-18 04:55:18
【问题描述】:

我想用 AndroidAnnotations 构建一个 Android 应用。

这是 GitHub 上未能构建/预处理的简化版本:https://github.com/aiQon/androidannotationsexample

应用程序由一个主应用程序模块和一个库模块组成。 两者都使用 AndroidAnnotations (AA)。 lib 模块有一种解决方法,可以在调试版本中找到 AndroidManifest.xml(它指的是发布清单,因为 gradle 不会为 lib 构建调试变体)。

但是,可以找到库模块的清单,但找不到主应用程序的清单。 主app的gradle文件是:

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.1"

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


apt {
    arguments {
        androidManifestFile variant.outputs.processResources.manifestFile
        resourcePackageName android.defaultConfig.applicationId
   }
}

dependencies {
    compile project(":mylibrary")
    apt "org.androidannotations:androidannotations:3.2+"
    compile 'org.androidannotations:androidannotations-api:3.2+'
}

Gradle 抱怨: http://pastebin.com/QZtnHcZD

有人能指出正确的方向吗?如何构建这个简化的项目以在 lib 模块中有一个控制器 Bean,并使用 AA 在主应用程序活动中成功引用它?

感谢您的帮助。

【问题讨论】:

  • 让我们将讨论移至here

标签: android gradle android-gradle-plugin android-annotations


【解决方案1】:

自 android gradle plugin 14.4 起,以下行不再起作用:

variant.outputs.processResources.manifestFile
variant.processResources.manifestFile

你必须改用这个:

variant.outputs[0].processResources.manifestFile

请注意,如果您有多个输出(使用拆分时),您可能需要使用另一个输出(非零索引)。

【讨论】:

    【解决方案2】:

    好的,我明白了。正在使用 Canary 频道的 Android Studio。回到 Beta 解决了这个问题,因为我可以使用 android gradle 插件 0.12.2。这解决了一切。

    【讨论】:

      猜你喜欢
      • 2019-12-30
      • 2021-03-08
      • 2019-01-28
      • 2014-07-20
      • 2019-03-31
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 1970-01-01
      相关资源
      最近更新 更多