执行任务:[clean, :app:assembleDebug] ERROR - Android Studio 3

Executing tasks: [clean, :app:assembleDebug] ERROR - Android Studio 3

我是 android 工作室的新人。我正在制作我的第一个应用程序,在以前的 2.3 版本中,我在制作应用程序时没有遇到问题或卡住。但是当我升级到新版本 3.0 时我遇到了问题,当我试图重建 apk 时。它停留在 Executing tasks: [clean, :app:assembleDebug] 。当我构建 apk、重建和清理时出现同样的问题。

有人可以帮忙解决这个问题吗?

我仍然无法解决这个问题。

10 actionable tasks: 9 executed, 1 up-to-date

Executing tasks: [clean, :app:assembleDebug]

    Parallel execution with configuration on demand is an incubating feature.
    :clean
    :app:clean
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild
    :app:compileDebugAidl
    :app:compileDebugRenderscript
    :app:checkDebugManifest
    :app:generateDebugBuildConfig
    :app:prepareLintJar UP-TO-DATE
    :app:generateDebugResValues
    :app:generateDebugResources
    :app:mergeDebugResources
    Exception in thread "queued-resource-processor_4" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\kreuzell\AppData\Local\Android\Sdk\build-tools.0.2\aapt2.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
        at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:196)
        at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
        at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:213)
        at java.lang.Thread.run(Thread.java:745)
    Exception in thread "queued-resource-processor_2" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\kreuzell\AppData\Local\Android\Sdk\build-tools.0.2\aapt2.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
        at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:196)
        at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
        at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:213)
        at java.lang.Thread.run(Thread.java:745)
    Exception in thread "queued-resource-processor_1" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\kreuzell\AppData\Local\Android\Sdk\build-tools.0.2\aapt2.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
        at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:196)
        at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
        at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:213)
        at java.lang.Thread.run(Thread.java:745)
    Exception in thread "queued-resource-processor_3" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\kreuzell\AppData\Local\Android\Sdk\build-tools.0.2\aapt2.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
        at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:196)
        at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
        at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:213)
        at java.lang.Thread.run(Thread.java:745)

一些 Android Studio 3.0 用户有类似的构建错误。

您的错误日志显示:

Exception in thread "queued-resource-processor_4" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\kreuzell\AppData\Local\Android\Sdk\build-tools.0.2\aapt2.exe can run successfully **(some anti-virus may block it)** or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds

这意味着,如果您的 Internet 连接正常,您的 aapt 进程 可能被防病毒软件或防火墙阻止。尝试禁用您的 防病毒软件 并重新构建。

如果不起作用,您可以尝试像这样禁用 AAPT2:

Improved incremental resource processing using AAPT2, which is enabled by default. If you are experiencing issues while using AAPT2, you can disable it by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

将其放入系统变量中:

SLAVE_AAPT_TIMEOUT = 30 

然后重新启动 Windows,对我来说效果很好。