在上安卓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博客https://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://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
文章来源:https://www.toymoban.com/news/detail-757022.html
8.然后再重新同步项目与Gradle文件,Ok了,不报错了,可以运行了。
文章来源地址https://www.toymoban.com/news/detail-757022.html
到了这里,关于Android Studio报错Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup f的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!