在导入一个 kapt 插件时,要求在 app 的 build.gradle 中配置:
apply plugin: 'kotlin-kapt'
但是配置之后仍旧出现错误:
Gradle DSL method not found: 'kapt()'
Possible causes:
The project 'My Application' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 4.0.1 and sync project
The project 'My Application' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
明明已经加了 apply 了,还是出现,搜索解决方案未果(都是要求添加 kotlin-kapt
的)实际上 plugin kotlin-kapt
还依赖于 kotlin-android
在 apply plugin: 'kotlin-kapt'
前再添加一项,修改后如下:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'