圆咕噜咕噜 发表于 2024-6-10 19:53:27

Android Studio报错Caused by: org.codehaus.groovy.control.MultipleCompi

在上安卓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.打开新项目,选择要打开的项目,并信托此项目

https://img-blog.csdnimg.cn/d67ec6d3dab74abb8de0d9f83bbb522b.png
https://img-blog.csdnimg.cn/0c099933ae8e415684297badd7483825.png
https://img-blog.csdnimg.cn/e064a229a49d4e9d8424c5a13dfcd364.png
2.点击“OK”(这个是程序没有在Android安装的文件中找到sdk,但是在其他地方找到了,询问受否同意打开找到的sdk)

https://img-blog.csdnimg.cn/6c185322990447f2beaca068f4f4a1ec.png
(如果下载Gradle速度过慢,可以手动下载,具体请跳转至:Android Studio手动下载Gradle文件放到指定目录_gradle下载后应该放在哪个文件夹-CSDN博客https://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/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博客https://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=N7T8https://blog.csdn.net/Qhx20040819/article/details/131911031
https://img-blog.csdnimg.cn/c5a8993a564e4dfe83ae07896611c96c.png
4.更改版本对应关系:File --> Settings... --> Build,Execution,Deployment --> Build Tools --> Gardle --> Gradle projects --> Gradle JDK

https://img-blog.csdnimg.cn/8b2e401a52d14c4a859bdc19b0091b5e.png
https://img-blog.csdnimg.cn/39e12def3f3a40a79538f5fec89c339c.png
5.点击右边的下拉按钮,点击“Download JDK...”下载匹配的版本,选择好版本相匹配的jdk文件地点,然后点击OK。

https://img-blog.csdnimg.cn/69b1828ae0ca472fa6cd903d205e6d9d.png
https://img-blog.csdnimg.cn/401d64571d894578b7f353109eef7eb8.png
6. 版本降低后必要同步gradle设置 File->Sync Project with Gradle Files(或者直接在工具栏同步)

https://img-blog.csdnimg.cn/957e9ccc16f74fad9741539bf271e51f.png
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 https://img-blog.csdnimg.cn/01a3ca3f82344c68979e2d0c10012a6a.png
https://img-blog.csdnimg.cn/204e70c1a54544c1983180d4fcbfc6ea.png
https://img-blog.csdnimg.cn/e87d19ce9c22430ab49442c86e6cd836.png
8.然后再重新同步项目与Gradle文件,Ok了,不报错了,可以运行了。

https://img-blog.csdnimg.cn/8db39cc2859c459bbe4329390765ab8b.png

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Android Studio报错Caused by: org.codehaus.groovy.control.MultipleCompi