Android Tutorial How to fix the multiple native libraries problem

Discussion in 'Tutorials & Examples' started by wonder, Nov 10, 2018.

  1. wonder

    wonder Expert Licensed User

    Error:
    It might happen that, when combining multiple native (JNI) libraries, your Android app will crash with an UnsatisfiedLinkError.

    Why does this happen?
    Well long-story-short, your libraries differ from each other in terms of ABIs (target CPU architecture).
    For a detailed explanation, please follow the link below (also attached in PDF format).
    https://www.neotechsoftware.com/blog/native-libraries-part-i-common-pitfalls
    upload_2018-11-11_11-16-56.png

    How to fix it?
    Let's say your project utilizes libA (ARM, x86), libB (ARM, ARMv7, x86) and libC (ARM, x86, MIPS).
    It's already obvious that such project will only work on ARM and x86 architectures.
    So basically, you need to remove the unnecessary ABIs folders.

    Step 1: Find out which libraries target unsupported architectures
    - Open your APK with 7Zip (right-click, open with...), go to lib and explore the sub-folders
    - Find the lowest common denominator: in our example that's ARM and x86
    - Close the APK file without making any changes

    Step 2: Modify the libraries
    -
    Go to your B4A External Libs folder and make copies of libB.jar and libC.jar (in the same folder)
    - Open the libB and libC copies with 7Zip
    - libB: go to libs, delete the ARMv7 folder
    - libC: go to libs, delete the MIPS folder
    - Refresh the B4A libs and select the modified ones

    Result:
    All of your project's native libraries now target exactly the same architectures: ARM and x86!
    The error should be gone (works for me)! :)
     

    Attached Files:

    Last edited: Nov 11, 2018
    hatzisn, Peter Simpson, Erel and 2 others like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice