当前位置:   article > 正文

解决AS编译报错:Failed to apply plugin [id com.android.application]_failed to apply plugin 'com.android.application'.

failed to apply plugin 'com.android.application'.

1、issue

解决AS编译报错:Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id ‘com.android.application’]

解决方法:在gradle.properties文件中添加android.overridePathCheck=true就可以了。

从日志第一句可以看出,应该是项目路径包含中文字符串,可以把项目移动到没有中文字符的路径中,也可以通过添加android.overridePathCheck=true解决。

2、issue

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

主要问题是 SDK 构建工具 31 中缺少的两个文件是:

  1. dx.bat
  2. dx.jar

解决方法是将这些文件在文件位置命名为 d8,因此将它们的名称更改为 dx 将解决错误。

对于 Windows

  1. 前往地点

     "C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0"(SDK的安装路径)
    
    • 1
  2. 找到一个名为 d8.bat 的文件。这是一个 Windows 批处理文件。

  3. 将 d8.bat 重命名为 dx.bat。

  4. 在文件夹 lib (“C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0\lib”)

  5. 将 d8.jar 重命名为 dx.jar

记住 AppData 是一个隐藏文件夹。打开隐藏项目以查看 AppData 文件夹。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/981359
推荐阅读
相关标签
  

闽ICP备14008679号