Gradle无法找到清单文件

时间:2015-12-09 17:09:29

标签: android gradle android-annotations

我正在尝试构建一个项目但是当我尝试从命令行构建它时出现以下错误:

error: Could not find the AndroidManifest.xml file, going up from path [C:\Users\User\Documents\work
space\app\app\app\build\generated\source\apt\debug] found using dummy file []
(max atempts: file:///C:/Users/User/Documents/workspace/app/app/app/build/generated/source/apt/debug/dummy1449680140847.java)

我的manifest.xml位于项目结构的主要支柱之下。 这是我的gradle文件:

import com.android.builder.core.DefaultManifestParser

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}



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

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.ponideapps.recetapp"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

// This is important, it will run lint checks but won't abort build
lintOptions {
    abortOnError false
}

task srcZip(type: Zip) {
    from projectDir
    def manifestParser = new DefaultManifestParser()
    def versionName = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
    archiveName = "${project.name}-${versionName}.${extension}"
    exclude 'build', 'gen', 'bin', '.DS_Store', '.settings', 'local.properties', '.gradle', '*.apk', '.idea', '*.iml', '*.log',
            '*/build', "*/gen", "*/bin", '*/*.iml', '*/*.log'
}
assemble.dependsOn srcZip
}

 allprojects {
  repositories {
     mavenCentral()
 }
}

android.applicationVariants.all { variant ->
  println "Defining task generate${variant.name.capitalize()}Javadoc"
  task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
    description "Generates Javadoc for $variant.name."
    source = variant.javaCompile.source

    //source = files()
    //variant.sourceSets.each{ sourceSet ->
    //    sourceSet.javaDirectories.each{ javaDirectory ->
    //        //println("adding source dir for javadoc generation: " + javaDirectory)
    //        source += files(javaDirectory)
    //    }
    //}
    //source += files("$buildDir/generated/source/r/" + variant.dirName)

    ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
    classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)

    //why doesn't this help? This should add the classfiles for the apt & R files
    //+ files("$buildDir/intermediates/classes/" + variant.dirName)

    //this would allow markdown comments, however, the plugin seems to be broken and always claims it cannot write a file it has just written :(
    //options.doclet = 'com.visural.doclets.markdown.standard.Standard'
    //options.docletpath = ["./libs/MarkdownDoclet-3.0.jar"]

    options.links("http://docs.oracle.com/javase/7/docs/api/", "http://www.joda.org/joda-time/apidocs/");
    //this is necessary to create links to the android documentation: the android website does not
    //contain the list necessary to create javadoc, the local installation does
    options.linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference");

    exclude '**/BuildConfig.java'
    exclude '**/R.java'

    options.memberLevel = JavadocMemberLevel.PROTECTED

    //this is very much necessary, as the apt files & the R.class would    otherwise break the javadoc
    failOnError false
  }
}


 dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:22.2.1'
 compile 'com.android.support:design:22.2.1'
 //android annotations
 compile files('libs/androidannotations-api-3.0.1.jar')
 apt files('libs_annotations/androidannotations-3.0.1.jar')
  }



apt {
   arguments {
    resourcePackageName "com.ponideapps.recetapp"
 }
}

某人在哪里出现问题? 非常感谢你提前!

1 个答案:

答案 0 :(得分:5)

添加:

apt {
   arguments {
    resourcePackageName "com.ponideapps.recetapp"
    androidManifestFile variant.outputs[0]?.processResources?.manifestFile
 }
}