【问题标题】:Android Studio says FAILURE: Build failed with an exception after updating to 3.6.2Android Studio 说 FAILURE: Build failed with an exception after update to 3.6.2
【发布时间】:2022-02-25 05:41:31
【问题描述】:

我所有的代码都运行良好。但是当我将 android studio 更新到 3.6.2 时,它显示:

Executing tasks: [:app:assembleDebug] in project /home/AK_47/AndroidStudioProjects/MyProject

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
   > Could not resolve com.android.tools.build:aapt2:3.6.2-6040484.
     Required by:
         project :app
      > No cached version of com.android.tools.build:aapt2:3.6.2-6040484 available for offline mode.
      > No cached version of com.android.tools.build:aapt2:3.6.2-6040484 available for offline mode.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
5 actionable tasks: 1 executed, 4 up-to-date

我正在尝试制作一个 ANDROID 应用程序。但是更新后就不行了。有什么解决办法吗?

【问题讨论】:

  • 请确保您已连接到互联网

标签: android-studio gradle


【解决方案1】:

尝试通过位于 Android Studio 右侧的 Gradle 工具关闭 Gradle 离线模式。 那么请按照以下步骤操作:

运行以下命令清除 gradle 缓存:

 rm -rf ~/.gradle/caches/

之后,请从文件菜单中单击Invalidate Caches/Restart,然后会进行进一步处理,再次下载所有库,因此需要一些时间,但也解决了这个问题。

【讨论】:

    【解决方案2】:

    该错误表示无法下载依赖项,因为您处于离线模式或活动的 Internet 连接不可用。 尝试的步骤

    1. 尝试关闭 Gradle 的离线模式。你被关闭了
    View > Tool Windows > Gradle
    

    从菜单栏。在 Gradle 窗口的顶部,单击 Gradle 窗口中的 Toggle Offline Mode 按钮。

    1. 检查互联网连接并重新构建。

    希望这个答案会有所帮助...

    【讨论】:

      【解决方案3】:

      我在 Gradle 使用 rm -rf ~/.gradle/ 然后gradle clean build 还有./gradlew test

      【讨论】:

        猜你喜欢
        • 2018-10-27
        • 2019-06-11
        • 1970-01-01
        • 2021-07-30
        • 1970-01-01
        • 2018-10-05
        • 2023-01-21
        • 2021-02-01
        • 2018-03-03
        相关资源
        最近更新 更多