程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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

开发过程中遇到删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class的问题如何解决?下面主要结合日常开发的经验,给出你关于删除 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 库中的那些依赖项。

大佬总结

以上是大佬教程为你收集整理的删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class全部内容,希望文章能够帮你解决删除 LeakCanary 反编译不相关的库文件,将文件从 .kt 转换为 .class所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。