简体   繁体   English

Android:NoSuchMethodError与接口中的静态方法(使用Retrolambda)

[英]Android: NoSuchMethodError with static method in interface (using Retrolambda)

In my project I am trying to use code written in Java 8 in Android app using Retrolambda plugin and Lightweight-Stream-API to bypass code compatibility. 在我的项目中,我尝试使用Android应用中使用Retrolambda插件和Lightweight-Stream-API编写的Java 8代码来绕过代码兼容性。 The source project runs well on Java platform (clarified). 源项目在Java平台上运行良好(已阐明)。

After porting the code to Android, I only had to make slight modifications in code (mostly about getting instance of com.annimon.stream.Stream class, because arrays and collections in Android lack method .stream() so I need to use static methods of Stream class with array/collection as parameter), but this shouldn't even be the concern of my problem. 将代码移植到Android之后,我只需要对代码做些微修改(主要是获取com.annimon.stream.Stream类的实例,因为Android中的数组和集合缺少方法.stream()所以我需要使用静态方法流类(以数组/集合作为参数),但这甚至不应该成为我的问题。 Currently there are no compilation errors, the application starts, works, but is crashing upon calling: 当前没有编译错误,该应用程序可以启动,运行,但是在调用时崩溃:

Optional<Room> result = INamed.getO(name, Stream.of(rooms));

With an error: 出现错误:

FATAL EXCEPTION: main

Process: cz.alois_seckar.vseadventrura, PID: 8109

java.lang.NoSuchMethodError: No static method getO(Ljava/lang/String;Lcom/annimon/stream/Stream;)Lcom/annimon/stream/Optional; in class Lcz/alois_seckar/vseadventrura/eu/pedu/adv16s_fw/game_txt/INamed; or its super classes (declaration of 'cz.alois_seckar.vseadventrura.eu.pedu.adv16s_fw.game_txt.INamed' appears in /data/data/cz.alois_seckar.vseadventrura/files/instant-run/dex/slice-slice_1-classes.dex)
    at cz.alois_seckar.vseadventrura.eu.pedu.adv16s_fw.test_util.default_game_txt.game.Apartment.getORoom(Apartment.java:166)
    at cz.alois_seckar.vseadventrura.eu.pedu.adv16s_fw.test_util.default_game_txt.game.Room$$Lambda$1.apply(Unknown Source)
    at com.annimon.stream.Stream$12.nextIteration(Stream.java:539)
    ...

And the class Room implements INamed through its ancestors ( Room extends AItemContainer that extends ANamed that implements INamed ). 和阶级Room实现INamed通过其祖先( Room延伸AItemContainer扩展ANamed实现INamed )。

So I dont really understand, what shall be the problem. 所以我真的不明白,这将是什么问题。 I would suspect Retrolambda plugin doesnt work exactly same as Java 8 does, but unable to tell what to change and how... Also the problem may be completely elsewhere, I am only beginning with Android... 我怀疑Retrolambda插件的功能 Java 8完全不同,但是无法告知要更改的内容和方式...问题也可能完全在其他地方,我只是从Android入手...

I can provide more code, if needed, but I think everything important has been told. 如果需要,我可以提供更多代码,但是我认为所有重要信息都已被告知。 Thanks in advance for any help. 在此先感谢您的帮助。

Problem solved: I have found out it is Retrolambda's fault - or rather my fault. 解决的问题:我发现这是Retrolambda的错-或更确切地说是我的错。 I overlooked the fact, that I have to enable support for default and static methods in Retrolambda's config in build.gradle 我忽略了一个事实,我必须启用Retrolambda在配置默认和静态方法支持build.gradle

The simple code goes like: 简单的代码如下:

retrolambda {
    defaultMethods true
}

After I did that, Retrolambda did all the back-end stuff and the method is being found now. 之后,Retrolambda完成了所有后端工作,并且现在可以找到该方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android AdMob-NoSuchMethodError:无静态方法zzand() - Android AdMob - NoSuchMethodError: No static method zzand() Error using Retrofit Builder in Android app: java.lang.NoSuchMethodError: No static method metafactory - Error using Retrofit Builder in Android app: java.lang.NoSuchMethodError: No static method metafactory Android:java.lang.NoSuchMethodError:没有静态方法zzy。 - Android: java.lang.NoSuchMethodError: No static method zzy. Android:NoSuchMethodError:没有静态方法zzy(Ljava / lang / Object; - Android: NoSuchMethodError: No static method zzy(Ljava/lang/Object; Android JNI java.lang.NoSuchMethodError:没有非静态方法 - Android JNI java.lang.NoSuchMethodError: no non-static method Android Studio java.lang.NoSuchMethodError:没有静态方法encodeHexString - Android Studio java.lang.NoSuchMethodError: No static method encodeHexString Android JNI 错误:NoSuchMethodError:没有非静态方法 - Android JNI Error: NoSuchMethodError: no non-static method Android AdMob方法上的NoSuchMethodError - NoSuchMethodError on Android AdMob method Android Room:“NoSuchMethodError: No interface method”用于更新的 Dao 方法,使用 Room.inMemoryDatabaseBuilder - Android Room: 'NoSuchMethodError: No interface method' for Dao methods that update, with Room.inMemoryDatabaseBuilder java.lang.NoSuchMethodError:排序arraylist android时没有接口方法sort(Ljava/util/Comparator;)异常 - java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;) exception in sorting arraylist android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM