【问题标题】:After updating android studio 3.0 unable to build the project更新android studio 3.0 后无法构建项目
【发布时间】:2017-10-31 10:00:12
【问题描述】:

android.enableAapt2=false 添加在 gradle.properties 底部
gradle.properties

http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel=true
    android.enableAapt2=false

build.gradle 更新 sdk 工具到 26 版本后更新 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

【问题讨论】:

  • 正如您的错误日志所建议的那样,仔细检查所有资源是否都在那里。该错误表明您缺少一些资源
  • android.enableAapt2=false 评论此行并检查。
  • 注释 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 失败
  • 它应该下载 app-compat-v7 : 26 on gradle sync。你能验证一下是否已经下载了吗?
  • 与 Android Studio 打交道时,首先要确保您已连接到 Internet。其次,正如已经建议的那样,Android Studio 告诉您在 mipmap 文件夹和 values/styles.xml 文件中缺少资源。因此,请确保这些资源存在。最后,如果未完成同步 gradle,则清理项目并最终重建它。如果这对您不起作用,请删除 buildToolsVersion 行并重复上述步骤。

标签: android android-studio android-studio-3.0


【解决方案1】:

我遇到了同样的问题:错误:任务 ':app:processDebugResources' 的执行失败。

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Development\Android\Sdk\build-tools\26.0.2\aapt.exe' ' 以非零退出值 1 结束

这个问题是由于这个:我在style.xml中声明了不正确的样式。

<!--<declare-styleable name="mapStyle"><attr name="layout_width"/><attr name="layout_height"/><attr name="layout_weight"/></declare-styleable>-->

当我评论它时,它工作正常。 所以检查你的style.xml

【讨论】:

    【解决方案2】:

    非常仔细检查您的清单和样式文件。其中可能有错误。特别是如果您在 styles.xml 中创建了自定义样式。

    在那之后构建->清理项目,它应该可以工作

    【讨论】:

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