# android

Kamo Spertsyan

03/23/2023, 10:20 AM
Hello. Please, help me understand the following error. It appears in rare devices and I can't even get what is it about.
Copy code
Fatal Exception: java.lang.NoSuchMethodError: No direct method <init>(Lcom/myApp/android/pckg/MyService;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V in class Lcom/myApp/android/pckg/MyService$doSmth$1; or its super classes (declaration of '$doSmth$1' appears in /data/app/blahblahblah==/base.apk!classes3.dex)
As far as I understood it should be a constructor call with three arguments (MyService class and two functions with one parameter). But there is no such a call in the line where the error points to and also no such a constructor. The error points to the line inside the
method where there is a call to the function
private fun executeOnMainThread(request: (ArgumentClass?) -> Unit) {}
which synchronizes the thread by a class lock. By the call I also provide an inline lambda function with the requested signature. Maybe the error for some reason occurs while creating that lambda? The only hook I have is the signature of the
method - it accepts two functions with one argument and returns nothing, so if this
can be explained as - MyService has a function accepting two functions with one argument and returning Void, then it makes sense. But still I cant understand, what does this class name means:
- there is no anonymous classes in that method especially at the line pointed by the error. And what is this
at the end? I would appreciate any help in understanding this error.
😶 1


03/23/2023, 12:31 PM
In android studio there is an option to „decompile to Java“. Maybe that gives more insights on what bytecode is generated by your Kotlin code.
👀 1
🙏 1


03/24/2023, 6:41 AM
Function1 is the signature for lambdas. If you consume a kotlin method with lambdas in Java, Function1 is the class used to create it. Maybe a DI tool is playing tricks on you? Perhaps the service is being recreated and the tool attempts to reach a non existent init method?

Kamo Spertsyan

03/24/2023, 7:40 AM
Yes, my function
consumes two lambdas. And the
method either. By the way I still can't understand where is the problem. I will try Christian's suggestion with decompiling to get more info.. Speaking of DI - I don't this it can be the reason as the problem occurs after the direct call. The service is created once per launch and doesn't recreated.