androidstudio导入别人的代码后编译报错:New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin version
看错误提示应该是kotlin版本不兼容问题导致无法完成Gradle构建。
于是搜索到这个文章:
而实际上,最后不仅修改了Language下的Kotlin语言的版本,也重新提高了新的Gradle构建版本,问题便得到解决。
如果还解决不了,可以看看是不是AndroidStudio版本太老导致的,可以升级到最新的稳定版,这里是升级AndroidStudio版本到了4.1.3
以下是上面链接文章的具体内容:
What Is Error ?
When trying to add cloud_firestore to my app, I have the following issue in my stack track.
Error message
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.android.tools.idea.gradle.project.sync.ng.NewGradleSyncNotSupportedException: New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin version
at com.android.tools.idea.gradle.project.sync.ng.SyncProjectModels.failIfKotlinPluginApplied(SyncProjectModels.java:108)
at com.android.tools.idea.gradle.project.sync.ng.SyncProjectModels.failIfKotlinPluginApplied(SyncProjectModels.java:111)
at com.android.tools.idea.gradle.project.sync.ng.SyncProjectModels.populate(SyncProjectModels.java:84)
at com.android.tools.idea.gradle.project.sync.ng.SyncAction.execute(SyncAction.java:59)
Cause 2: org.gradle.internal.exceptions.LocationAwareException: New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin version
Solutions
New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin version
Question : How to solve New Gradle Sync not supported due to containing Kotlin modules using unsupported plugin version ?
Answer : This issue cause of JVM version. Solution of this error to update JVM version in kotlin compiler Setting with this instruction.
Solution 1
This issue cause of JVM version. Solution of this error to update JVM version in kotlin compiler Setting with this instruction.
- So, I had to update my JVM Version in Kotlin Compiler settings.
- You can find that setting here: File -> Settings -> Kotlin Compiler -> Target JVM Version
- Changing to
1.8
fixed the issue.
Solution 2
It could be that your IDE has an older level of the Kotlin plugin.
Within Android Studio, got to File
> Settings...
> Kotlin
and check to make sure your plugin is up to date. You may see something like this, indicating you need to update:
Solution 3
First Check your JVM version
- Open Window
- Go to Java from Programs
- Open ‘About Java’ and this will show you the version of your JVM
Now Update JVM version in your Android Studio
- File -> Settings.. -> Kotlin Compiler
- Go to ‘Target JVM Version’
- Select the version that your JVM have.
That’s it. Your studio will build again automatically..
Solution 4
For Mac(Catalina) Users
- Select Android Studio (This is hidden, move your cursor to the top of the screen to reveal this option)
- Then,
- Preferences -> Kotlin Compiler -> Target JVM Version
- now modify the respective java version, I changed Target JVM version from 1.6 to 1.8 to make it work.
- Shortcut to open Preferences in Android Studio is
Cmd + ,
Hope This Above 4 Solution Will Work For You Too. So it’s all About this error. Hope this article helped you a lot. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.