Java and B4A wrapper for a native .so library

Discussion in 'Job Offers' started by divinglog, Jun 12, 2019.

  1. divinglog

    divinglog Member Licensed User

    Hello

    I want to use a native C-Library in B4A and as far as I know, the only way to get this working is creating a Java wrapper around the native .so library and then a B4A wrapper for the Java wrapper. So if someone can help me to do this, please contact me.

    The native library I want to consume is: https://github.com/libdivecomputer/libdivecomputer

    I'm using this lib for several years in my VB.NET project on Windows with pinvoke and I can provide my VB.NET code as a reference. Because special hardware is required for testing, I do NOT expect a ready to use wrapper. A scaffolding with some functions and callbacks should be sufficient for me to complete the project.

    Requirements:

    - You have to be able to create a Java wrapper for a native .so library
    - You have to know how to create a B4A wrapper for the Java wrapper
    - You have to know how to call C-code functions from Java and B4A and how to receive callbacks from native code
    - It would be helpful if you understand VB.NET code, as I can provide this code as a reference

    If there is a better way to consume a native .so library in B4A, please let me know.

    You can contact me here in the forum or via Email: info (at) divinglog.de

    Thank you,
    Sven Knoch
     
  2. DonManfred

    DonManfred Expert Licensed User

    If you find someone who can compile the .so and create the javawrapper for the native then i can help you creating a b4a wrapper.
    If you have contact to the developer. He should be able to create a file like

    libdivecomputerJNI.java

    with a content like
    Code:
    package com.fos.sdk; // Adapt here

    import java.util.ArrayList; // Adapt 
    if needed

    public class DiveComputerJNI {
        
    public static native int AddAccount(int i, int i2, String str, String str2, int i3);

        
    public static native int AddMultiDev(int i, int i2, MultiDevice multiDevice);

        
    public static native int AddMusicList(int i, int i2, MusicList musicList, CurListInfo curListInfo);

        
    public static native int AecCloseAudio();

    [...]
        static {
            
    try {
                System.loadLibrary(
    "divecomputer");
            
    } catch (UnsatisfiedLinkError e) {
                e.printStackTrace();
            }
    }
     
  3. DonManfred

    DonManfred Expert Licensed User

    beside this we need native .so files for 32 and 64bit and for all architectures.
     
  4. divinglog

    divinglog Member Licensed User

    Thank you DonManfred! Yes, compiling the .so library is something I'll look into. I'm able to compile the Windows DLL, so I think compiling with the Android NDK shouldn't be a problem.
     
    DonManfred likes this.
  5. divinglog

    divinglog Member Licensed User

    Just a small update, I was able to compile the .so libraries for ARM32 and ARM64 architectures.
     
    DonManfred likes 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