老项目放到新AS上面报错:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
--------------------------
Unsupported Gradle JVM.
Your build is currently configured to use Java 17.0.11 and Gradle 6.8.2.
Possible solutions:
- Upgrade to Gradle 8.5 and re-sync
- Upgrade to Gradle 7.2 and re-sync
因为Java和Gradle的版本不匹配导致的,查看版本对应关系可跳转至:
更改版本对应关系:File --> Settings... --> Build,Execution,Deployment --> Build Tools --> Gardle --> Gradle projects --> Gradle JDK 点击右边的下拉按钮,点击“Download JDK...”下载匹配的版本,选择好版本相匹配的jdk文件地址,然后点击OK。
版本降低后需要同步gradle设置 File->Sync Project with Gradle Files(或者直接在工具栏同步)
此时又报出新的错误:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'com.android.internal.application'.
解决方法:
在gradle.properties文件最后添加:
android.overridePathCheck=true