Building application with library module can not find AndroidManifest.xml

advertisements

I want to build an Android App with AndroidAnnotations.

Here is a simplified version on GitHub which fails to build/pre-process: https://github.com/aiQon/androidannotationsexample

The app is composed of a main app module and a library module. Both use AndroidAnnotations (AA). The lib module has a workaround to find the AndroidManifest.xml in debug builds (it refers to the release manifest, because gradle does not build the debug variant for libs).

However, the manifest is found for the library module but not for the main app. The gradle file of the main app is:

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 complains with: http://pastebin.com/QZtnHcZD

Could someone please point me in the right direction on how to build this simplified project to have a controller Bean in the lib module and reference it successfully in the main app activity by using AA?

I appreciate any help.


Since android gradle plugin 14.4, the following line does not work anymore:

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

You have to use this one instead:

variant.outputs[0].processResources.manifestFile

Please note if you have multiple outputs (when using splits), you may want to use another output (other index than zero).