NoSuchMethodException occurs when using Facebook Conceal library on Android P device.
Error Stacktrace:
java.lang.NoSuchMethodException: nativeLoad [class java.lang.String, class java.lang.ClassLoader, class java.lang.String]
at java.lang.Class.getMethod(Class.java:2068)
at java.lang.Class.getDeclaredMethod(Class.java:2047)
at com.facebook.soloader.SoLoader.getNativeLoadRuntimeMethod(SoLoader.java:297)
at com.facebook.soloader.SoLoader.initSoLoader(SoLoader.java:249)
at com.facebook.soloader.SoLoader.initImpl(SoLoader.java:156)
at com.facebook.soloader.SoLoader.init(SoLoader.java:131)
at com.facebook.soloader.SoLoader.init(SoLoader.java:115)
at com.facebook.soloader.SoLoader.init(SoLoader.java:142)
There is an open issue in the repository of the library: https://github.com/facebookarchive/conceal/issues/197
The problem relates to a Soloader dependency, which is part of the Conceal library. To resolve the issue, you need to remove the Soloader dependency from the Conceal library and add the new version (0.6.0) as a separate, independent dependency.
Here are the steps to achieve this:
-
Download the AAR file of the Conceal library from Maven Central.
-
Extract the content of the AAR file. You can use any ZIP extraction tool for this:
unzip conceal-2.0.1.aar -d conceal_extracted
-
Remove all Soloader files:
zip -d conceal_extracted/classes.jar com/facebook/soloader/*
-
Repackage the modified AAR file:
jar cvf com.facebook.conceal-2.0.1-modified.aar -C conceal_extracted .