這兩天對gradle進行了升級,出現以下錯誤提示,當時十分費解,找不到原因,后來經過排查插件引入,找到原因。
Unable to find method ''void com.android.build.api.dsl.ApplicationExtension.onVariantProperties(kotlin.jvm.functions.Function1)''
'void com.android.build.api.dsl.ApplicationExtension.onVariantProperties(kotlin.jvm.functions.Function1)'
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
過程中發現Gradle plugin版本只要是高于4.2.0就會出現這個錯誤,換回4.1.3并使用7.0.2的Gradle就沒有出現這個問題。
于是我新建了一個項目使用高版本的gradle和gradleplugin,發現并沒有出現該問題,所以我開始排查其它plugin的兼容性。
最后發現com.getkeepsafe.dexcount:dexcount-gradle-plugin的版本沒有升級,,dex分包插件的低版本沒有kotlin代碼分包的功能。而gradle最近的高版本(目前測試6.7.0以后含kotlin編譯,7.0以后更是主方向為kotlin)所以dex分包插件也要升級到高版本,含kotlin分包。至此問題解決。希望幫到遇到問題的人。