Java – Build Ant using .so files

Build Ant using .so files… here is a solution to the problem.

Build Ant using .so files

I’m working on a project with more than 65k methods, and I’m following the process of building the project Dex65536

In my project

, it contains some .so files for database encryption in my project. I get an error when applying an ant task with this custom rule

Warning:No implementation found for native 
Error: Lcom....... java.lang.UnsatisfiedLinkError: Native method not found:

How to resolve this issue and how to specify the .so file in the custom_rules.xml file.

Please advise.

Thanks in advance

Solution

If your APK contains .so in the Armeabi folder, then you don’t need to look at the Ant build process.

The error you receive is caused by a .so load failure or a function name wrong export/import.

Are you sure of the following:

    There is a .so library in your armeabi

  • and armeabi-v7a folders (you will need to have .so in both folders as some Android versions are in different folders) – extract the apk to ensure 100%.
  • The .so library is compiled for the correct schema for the target device
  • In your Java code, you call System.loadLibrary before any native code
  • Functions exported from your native code follow the correct naming:

For Java methods

int com.sample.NativeBridge.GetInt()

You need to export a pair of C methods

JNIEXPORT jint JNICALL Java_com_sample_NativeBridge_GetInt(JNIEnv env, jclass this)

Considering that you have a large number of methods, is it possible to split the original container class into multiple classes, at which point the C function name does not match the correct naming convention?

Related Problems and Solutions