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

Removing LeakCanary decompiles unrelated library file, turns a file from .kt to .class

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

当我清理完 classes(比如 30+ classes...)时,我完全删除了图书馆:

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

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

下面的消息出现在现在打开的 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 库,问题就会消失。

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

解决方案

罪魁祸首??

我不太清楚,我的猜测是我在实现 LeakCanary 后开始使用 CalendarView 库,所以错误从未出现。

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