Android Studio 3:找不到AndroidManifest.xml文件

6

在迁移到Android Studio 3后,我无法编译,因为出现了以下错误:

Error:Could not find the AndroidManifest.xml file, using  generation 
folder 
[/home/salacr/git/Evotech/app/build/generated/source/apt/debug])
Error:Parceler: Code generation did not complete successfully.  For 
more details add the compiler argument -AparcelerStacktrace
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

这可能与使用Android注释有关,我的app/build.gradle文件如下:

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

def AAVersion = '4.3.1'
def parcelerVersion = '1.1.9'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    signingConfigs {
        release {
            storeFile file("******")
            storePassword "******"
            keyAlias "******"
            keyPassword "******"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    splits {
        abi {
            enable true // enable ABI split feature to create one APK per ABI
            universalApk true //generate an additional APK that targets all the ABIs
        }
    }
    /*
    // map for the version code
    project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9]

    android.applicationVariants.all { variant ->
        // assign different version code for each output
        variant.outputs.each { output ->
            output.versionCodeOverride =
                    project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
        }
    }
    */

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {

    implementation "org.parceler:parceler-api:$parcelerVersion"
    annotationProcessor "org.parceler:parceler:$parcelerVersion"
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    implementation "org.androidannotations:androidannotations-api:$AAVersion"
    implementation 'com.android.support:appcompat-v7:26.0.1'
    implementation 'com.android.support:multidex:1.0.2'
}

我找不到这个问题的根本原因,有什么建议吗?我尝试了不同的gradle版本和使用不同的buildToolsVersion工具,但都没有效果。

有什么建议吗?

谢谢!

编辑1:我已经发现问题在这里:

splits {
    abi {
        enable true // enable ABI split feature to create one APK per ABI
        universalApk true //generate an additional APK that targets all the ABIs
    }
}

如果没有这个配置,一切都按预期工作。看起来这个配置与新版Android Studio中的androidanotations不兼容。

编辑2:在androidanotation中已经存在问题:https://github.com/androidannotations/androidannotations/issues/2034


答案在错误信息中:Error:Parceler: Code generation did not complete successfully. For more details add the compiler argument -AparcelerStacktrace。你尝试过这个吗? - bated
我已经完全从我的项目中移除了Parceler,但仍然出现以下错误: 错误:找不到AndroidManifest.xml文件,使用生成文件夹。 - ebolax
4个回答

6

我有类似的问题,当我将Android注释版本从4.4.0更新到4.5.0时,解决了我的问题。


2
我曾经遇到过这个问题,当时Android注解还没有发布修复程序,只能回滚到旧版本的Gradle。但是4.5.0及以上版本肯定会解决这个问题。 - Amit

5
defaultConfig下的build.gradle文件中添加以下代码。
   javaCompileOptions {
        annotationProcessorOptions {
            arguments = [
                    "androidManifestFile":"$projectDir/src/main/AndroidManifest.xml".toString()
            ]
        }
    }

0

我曾经遇到过类似的问题,当我将Android注释版本从4.4.0更新到4.6.0时,问题得到了解决。


0

我解决了这个问题,改变了gradle版本:

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接