Java 编译器错误,无法解析 R,构建失败

Java compiler error, cannot resolve R, build failed

我是新手,我的脚本有些问题

希望大家帮帮我

在这张图片中,我的 R 脚本无法解析,我的构建失败,Java 编译器错误

此构建失败日志

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:mergeDebugResources'.
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
   at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.build.gradle.tasks.ResourceException: Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

和这个 Java 编译器错误日志

Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

仅供参考

I have done all the ways to solve this problem from various sources such as threads on this web, google, and youtube but all did not work I really hope that some of you will be kind enough to help me solve this problem

谢谢

转到 android 工作室顶部的构建选项,点击重建项目或清理项目。

希望以后能好好工作

我前段时间遇到了同样的问题。转到 Gradle 脚本 --> build.gradle(项目:X)

并查找行

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

我不得不将这一行替换为

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha11'

更改该行后,我刚刚同步了 Gradle,这给了我一个错误并提示我下载文件。 在那之后它就像一个魅力。