微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class

如何解决删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class

我试图清理我的代码,因为 LeakCanary 库暴露了一些我无意中使用“@NotNull”而不是“@NonNull”的安卓注释。

当我清理完类(比如 30 多个类......)时,我完全删除了库:

//    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'

然后一个名为 CalendarView.kt https://github.com/kizitonwose/CalendarView.git一个不错的可定制日历)的无关库(完全用 Kotlin 编写)的主 .kt 文件变为 CalendarView.class

并且下面的消息出现在现在已转换的班级的顶部。

// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available

现在代码不起作用了。

编译器给我的错误如下:

class file for kotlin.jvm.functions.Function1 not found

整个错误

ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1D:\Projects\....java:143: error: cannot access Function1
                                calendarView.get().setMonthScrollListener(
                                                  ^
  class file for kotlin.jvm.functions.Function1 not found

如果我重新激活 LeakCanary 库,问题就会消失。

我真的不明白发生了什么......请帮忙!!

解决方法

解决方案

Tools > Kotlin > Configure Kotlin in Project > Android with Gradle and choose your Java module with Single module radio button selected then select your version and OK

罪魁祸首??

我真的不知道,我的猜测是我开始使用 CalendarView 库,在我实现 LeakCanary 之后,所以没有出现错误。

鉴于我的环境并未真正准备好处理 Kotlin,LeakCanary 库修补了一些要求,因此,新的 CalendarView 库开始使用 LeakCanary 库中的那些依赖项。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。