当前位置:   article > 正文

Android Studio报错Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup f

caused by: org.codehaus.groovy.control.multiplecompilationerrorsexception: s

在上安卓Android课的时候,用自己的Android Studio打开老师发的项目文件,报错出现

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Unsupported Java.

Your build is currently configured to use Java 17.0.6 and Gradle 6.7.1.

Possible solution:

 - Upgrade Gradle wrapper to 7.2 version and re-import the project

的问题,自己查阅资料百度出的解决方案,感觉挺有成就的,在这个记录一下。

1.打开新项目,选择要打开的项目,并信任此项目

2.点击“OK”(这个是程序没有在Android安装的文件中找到sdk,但是在其他地方找到了,询问受否同意打开找到的sdk)

(如果下载Gradle速度过慢,可以手动下载,具体请跳转至:Android Studio手动下载Gradle文件放到指定目录_gradle下载后应该放在哪个文件夹-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/u011046452/article/details/107529346

3.出现报错信息:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Unsupported Java.

Your build is currently configured to use Java 17.0.6 and Gradle 6.7.1.

Possible solution:

 - Upgrade Gradle wrapper to 7.2 version and re-import the project

这是因为Java和Gradle的版本不匹配导致的,查看版本对应关系可跳转至:

grdle 的安装与配置 、gradle和jdk版本对应关系_gradle jdk对应关系-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/Qhx20040819/article/details/131911031

4.更改版本对应关系:File --> Settings... --> Build,Execution,Deployment --> Build Tools --> Gardle --> Gradle projects --> Gradle JDK

5.点击右边的下拉按钮,点击“Download JDK...”下载匹配的版本,选择好版本相匹配的jdk文件地址,然后点击OK。

6. 版本降低后需要同步gradle设置 File->Sync Project with Gradle Files(或者直接在工具栏同步)

7.此时又报出新的错误:

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'com.android.internal.application'.

Caused by: org.gradle.api.tasks.StopExecutionException: Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by adding the line 'android.overridePathCheck=true' to gradle.properties file in the project directory.

解决方法:

gradle.properties文件最后添加:

android.overridePathCheck=true

8.然后再重新同步项目与Gradle文件,Ok了,不报错了,可以运行了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/318736
推荐阅读
相关标签
  

闽ICP备14008679号