更新了 Android Studio 3.0 后无法构建项目。

3
在 gradle.properties 的底部添加 android.enableAapt2=false。
http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel=true
    android.enableAapt2=false

更新sdk工具至26版本后,需要更新build.gradle文件。sdk工具已经是最新版本。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.example.madhural.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.github.tarek360.RichPath:animator:0.0.9'
    compile 'com.github.mmoamenn:LuckyWheel_Android:0.0.2'
    compile 'com.google.code.gson:gson:2.6.1'
    testCompile 'junit:junit:4.12'
}

构建完成后出现以下错误。
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
Error:No resource found that matches the given name (at 'icon' with value '@mipmap/ic_launcher').
Error:No resource found that matches the given name (at 'roundIcon' with value '@mipmap/ic_launcher_round').
Error:No resource found that matches the given name (at 'theme' with value '@style/AppTheme').
Error:No resource found that matches the given name (at 'icon' with value '@mipmap/ic_launcher').
Error:No resource found that matches the given name (at 'roundIcon' with value '@mipmap/ic_launcher_round').
Error:No resource found that matches the given name (at 'theme' with value '@style/AppTheme').
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\amin.p\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\amin.p\AppData\Local\Android\Sdk\platforms\android-26\android.jar -M \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\res\merged\debug -m -J \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\generated\source\r\debug -F D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.madhural.myapplication -0 apk --output-text-symbols \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\symbols\debug --no-version-vectors}
Error:com.android.ide.common.process.ProcessException: Error while executing process C:\Users\amin.p\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\amin.p\AppData\Local\Android\Sdk\platforms\android-26\android.jar -M \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\res\merged\debug -m -J \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\generated\source\r\debug -F D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.madhural.myapplication -0 apk --output-text-symbols \\?\D:\Gamify Your World\GamifyYourWorld\GYWGameApp\app\build\intermediates\symbols\debug --no-version-vectors}
Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\amin.p\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 13s
Information:10 errors
Information:0 warnings
Information:See complete output in console

1
正如您的错误日志所提示的那样,请仔细检查所有资源是否都存在。该错误表明您缺少某些资源。 - Century
android.enableAapt2=false 将此行注释并检查。 - Dee Nix
在下面注释android.enableAapt2=false后出现以下错误。 com.android.tools.aapt2.Aapt2Exception: AAPT2错误:详细信息请检查日志 错误:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception:AAPT2错误:请检查日志以获取详细信息 错误:com.android.tools.aapt2.Aapt2Exception:AAPT2错误:请检查日志以获取详细信息 错误:执行任务':app:processDebugResources'失败。
无法执行aapt
- Amin Pinjari
@nt.bas 项目中没有缺失,因为我已经有了mipmap文件夹等等。主要错误是Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\amin.p\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1。 - Amin Pinjari
@aminpinjari,请检查您的style.xml文件,是否已添加类似styleable等内容。如果存在问题,则会出现此错误。通过注释掉这部分内容,检查它是否正常运行。 - Mudassir Khan
显示剩余3条评论
2个回答

1
我遇到了相同的问题:错误:执行任务“:app:processDebugResources”失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程“命令'C:\ Development \ Android \ Sdk \ build-tools \ 26.0.2 \ aapt.exe'”以非零退出值1结束。
这个问题是由于我在style.xml中声明的stylable不正确导致的。
<!--<declare-styleable name="mapStyle"><attr name="layout_width"/><attr name="layout_height"/><attr name="layout_weight"/></declare-styleable>-->

当我注释掉它后,它就可以正常工作。 因此,请检查你的 style.xml

0
请仔细检查您的清单文件和样式文件,尤其是如果您在styles.xml中创建了自定义样式,可能会存在错误。
之后,进行“构建-清理项目”操作,这样就能够希望它正常工作了。

感谢您的建议,但问题已在接受的答案中得到解决。 - Amin Pinjari

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