在上安卓Android課的時(shí)候,用自己的Android Studio打開老師發(fā)的項(xiàng)目文件,報(bào)錯(cuò)出現(xiàn)
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
的問題,自己查閱資料百度出的解決方案,感覺挺有成就的,在這個(gè)記錄一下。
1.打開新項(xiàng)目,選擇要打開的項(xiàng)目,并信任此項(xiàng)目
2.點(diǎn)擊“OK”(這個(gè)是程序沒有在Android安裝的文件中找到sdk,但是在其他地方找到了,詢問受否同意打開找到的sdk)
(如果下載Gradle速度過慢,可以手動(dòng)下載,具體請(qǐng)?zhí)D(zhuǎn)至:Android Studio手動(dòng)下載Gradle文件放到指定目錄_gradle下載后應(yīng)該放在哪個(gè)文件夾-CSDN博客https://blog.csdn.net/u011046452/article/details/107529346
3.出現(xiàn)報(bào)錯(cuò)信息:
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
這是因?yàn)镴ava和Gradle的版本不匹配導(dǎo)致的,查看版本對(duì)應(yīng)關(guān)系可跳轉(zhuǎn)至:
grdle 的安裝與配置 、gradle和jdk版本對(duì)應(yīng)關(guān)系_gradle jdk對(duì)應(yīng)關(guān)系-CSDN博客https://blog.csdn.net/Qhx20040819/article/details/131911031
4.更改版本對(duì)應(yīng)關(guān)系:File -->?Settings... -->?Build,Execution,Deployment -->?Build Tools -->?Gardle --> Gradle projects -->?Gradle JDK
5.點(diǎn)擊右邊的下拉按鈕,點(diǎn)擊“Download JDK...”下載匹配的版本,選擇好版本相匹配的jdk文件地址,然后點(diǎn)擊OK。
6. 版本降低后需要同步gradle設(shè)置 File->Sync Project with Gradle Files(或者直接在工具欄同步)
7.此時(shí)又報(bào)出新的錯(cuò)誤:
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
文章來源:http://www.zghlxwxcb.cn/news/detail-757022.html
8.然后再重新同步項(xiàng)目與Gradle文件,Ok了,不報(bào)錯(cuò)了,可以運(yùn)行了。
文章來源地址http://www.zghlxwxcb.cn/news/detail-757022.html
到了這里,關(guān)于Android Studio報(bào)錯(cuò)Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup f的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!