当前位置:  开发笔记 > 编程语言 > 正文

Gradle找不到清单文件

如何解决《Gradle找不到清单文件》经验,为你挑选了1个好方法。

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

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> WonderCsabo..:

添加:

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

推荐阅读
落单鸟人
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有