为了账号安全,请及时绑定邮箱和手机立即绑定

如何将 Kotlin 文件添加到旧的 android java 项目?

如何将 Kotlin 文件添加到旧的 android java 项目?

慕尼黑5688855 2021-12-22 18:50:10
我正在尝试基于 ODK Collect 构建一个 android 应用程序。ODK Collect 应用程序是用 Java 编写的。我想使用 Kotlin 进行开发。我使用 android studio 新活动向导添加了一个基于 Kotlin 的空活动。当我尝试编译时,出现以下错误;Executing tasks: [:collect_app:assembleDebug]> Configure project :collect_appCould not find google-services.json while looking in [src/nullnull/odkCollectRelease, src/odkCollectRelease/nullnull, src/nullnull, src/odkCollectRelease, src/nullnullOdkCollectRelease]registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)collect_app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.google.dagger:dagger-android-processor:2.16', 'com.google.dagger:dagger-compiler:2.16', 'com.jakewharton:butterknife-compiler:8.8.1', 'com.google.dagger:dagger-compiler:2.16'.'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin'kapt.generateStubs' is not used by the 'kotlin-kapt' pluginODK 收集应用程序:https : //github.com/opendatakit/collect
查看完整描述

2 回答

?
Smart猫小萌

TA贡献1911条经验 获得超7个赞

此问题已在 Kotlin 版本 1.3.20 中修复。


查看完整回答
反对 回复 2021-12-22
?
梦里花落0921

TA贡献1772条经验 获得超5个赞

这里有一些事情可以尝试在每个之后重建。让我知道事情的后续。

尝试单击工具菜单 -> Kotlin -> 在项目中配置 Kotlin。

尝试点击工具菜单 -> Kotlin -> 配置 Kotlin 插件更新

尝试添加

apply plugin: 'kotlin-kapt'

尝试单击文件 -> 使缓存无效/重新启动

更新 添加到 build.gradle

kapt { generateStubs = true }


查看完整回答
反对 回复 2021-12-22
  • 2 回答
  • 0 关注
  • 167 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信