I've checked a few different questions, but none of them provided a solution which worked for me. I'm developing a project with Android Annotations, and when I attempt to build my project it fails with the following error (Project_Location is simply my local project folder):
error: Could not find the AndroidManifest.xml file in specified path : [/Project_Location/mobile/build/intermediates/manifests/full/debug/AndroidManifest.xml]
Here is my mobile build.gradle file:
apply plugin: 'com.android.application'
ext.androidAnnotationsVersion = '3.3.2';
ext.eventBusVersion = '2.4.0';
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'android-apt'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
apt "de.greenrobot:eventbus:${eventBusVersion}"
compile "de.greenrobot:eventbus:${eventBusVersion}"
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dev.app_name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
apt {
arguments {
androidManifestFile variant.outputs.processResources.manifestFile
resourcePackageName 'com.dev'
}
}
android.applicationVariants.each { variant ->
aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}
}
If the build.gradle file looks like a mess, I've tried to implement multiple solutions already without success. So if there's redundant statements that can be removed feel free to provide those suggestions as well. Right now, I'm just stumped as to why it can't locate my manifest file which is clearly present.
I fixed your build script which should be working regarding AndroidAnnotations:
apply plugin: 'com.android.application'
ext.androidAnnotationsVersion = '3.3.2';
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dev.app_name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName "com.dev.app_name" // the same as package in the manifest
}
}
Update: to use with annotationProcessor
instead of apt
:
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": "com.dev.app_name"]
}
}
}
}
And make sure you are using the latest version of AndroidAnnotations.
来源:https://stackoverflow.com/questions/34698477/android-annotations-could-not-find-androidmanifest-xml