在使用Google推出的Jetpack 库 CameraX时,
app 的build.gradle有如下内容 (部分截取)
apply plugin: 'com.android.application'
//kotlin-kapt插件Android的注解处理 java使用annotationProcessor 添加的依赖改为使用kapt
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Kotlin lang
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// App compat and UI things
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.core:core-ktx:1.0.2'
//CameraX
//core library.
def camerax_version = "1.0.0-alpha03"
implementation "androidx.camera:camera-core:${camerax_version}"
// If you want to use Camera2 extensions. like Portrait, HDR, Night, and Beauty
implementation "androidx.camera:camera-camera2:${camerax_version}"
// Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
kapt 'com.github.bumptech.glide:compiler:4.9.0'
}
//图片缓存
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
在kotlin中可以使用kapt插件来支持Android的注解处理
它把java使用annotationProcessor 添加的依赖改为使用kapt
参考: