java.lang.NoClassDefFoundError: Failed resolution of:$ExternalSyntheticLambda0;

Original link: http://i.lckiss.com/?p=8032

Background : I have seen a special case of online crash when kotlin and java are mixed together, which can be determined to be a crash caused by non-obfuscation/null pointer.

Affected models : Android 5.1.1, 6.0 vivo, oppo, Huawei and other old models.

Final solution : rewrite the kotlin part in java.

Details : One day there is a requirement for the product. The module involved in the requirement is the old code, the architecture is MVP, and Rxjava2 is used. A while ago, my colleague upgraded Rxjava to Rxjava3. I added some logic to the data layer and used new operators. zipWith , because it involves a request for a new interface, the data interface returned by the request involves multiple layers of nesting, and I am used to kotlin so I hate this way of writing:

 //pseudo code if(response !=null && response.Page!=null && response.Page.getItems()!=null)

Compared to kotlin it is:

 response?.Page?.getItems()?:emptyList()

So I happily submitted the code. After testing with the company’s test machine, no problems were found, and it went online as usual.

In the second week, I found that Tingyun crashed on the first day, and saw a few sporadic crashes. I thought that someone was using a low-version machine to work on our application, so I ignored it. On the second day, there was a customer feedback that the application would fail to start. Crash, then I noticed that there were real users using Android 6.0, and on the third day there was also a customer feedback crash on Android 5.1.1.

So I started repairing, I checked the problem location code, and finally located my kt class that implements BiFunction independently from zipWith. As for ExternalSyntheticLambda0, it is actually some anonymous classes generated by closures in kotlin, that is, the type of ()->Unit.

After my various attempts, such as using java to implement BiFunction, using kotlin to implement the content of the apply method, and running the cloud test, it failed. The installation of the cloud test was very slow, so after several subsequent attempts were unsuccessful , decided to completely rewrite it in java, and hand it over to the test after the test is no problem.

The only thing I couldn’t verify during this process was this way of writing kotin:

 fun a{   fun b(){}   //...   b() }

I suspect that this part of the code caused the crash, but I found that there are many such writing methods in the project, but there is no feedback of the crash. I didn’t go to write the demo verification, because I felt that it was a waste of time to write. If there is such a problem, it should be able to be found online, but I didn’t find any related problems.

So, it can only be left to nothing, maybe it is caused by what conversion is done in the operator of Rxjava3, but this thing is outdated, and some old codes are in use, they can be run and put there, and there is no one on the Internet to study anymore. Rxjava is out, and I don’t want to put too much effort into it.

Error posted here:

 java.lang.NoClassDefFoundError: Failed resolution of:Lcom.xxx.xxx.kt$ExternalSyntheticLambda0;

If someone steps on the pit in the future, if you know the reason and bother to let me know, it can be considered to satisfy my curiosity and see you for a long time.

This article is reproduced from: http://i.lckiss.com/?p=8032
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment