Need help on how to load .SO files and access an SO Class

jdiperla

Member
Licensed User
Longtime User
I basically have multiple SO Files compiled. I need to be able to access them via my B4A application and run a specific class in one of them. I have no idea where to start. Looking at all the help and searching the forums leaves me completely clueless as to what to do. I do not know Java, so I really want to be able to do this via B4A. Thoughts?
 

agraham

Expert
Licensed User
Longtime User
I tore up my first intended reply as the more I looked into it the more I realised my ignorance about native code production. However I can confidently say that you would need a custom Java library to load those SO files at runtime and expose them to Basic4android.

Assuming that these SO files were produced with the Android NDK it is not clear to me whether you can take an arbitrary SO file and just compile a free-standing jar to load and access it or, as what I have read implies, that you actually need to build the jar in conjunction with building the SO. However that may be moot as you say you have no Java experience.
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Hmmm... Any good tutorials to do something like this? I am not to great with Java.

Basically, I have a few files in the lib/armeabi folder. One is called libarkactivity.so and it calls the other SO files when it needs it. I just need to pass a few arguments to it when called. Thats its own application created in C++. I am using my B4A as an interface for that app.

So, to call libarkactivity.so I would do something like this? :

B4X:
import anywheresoftware.b4a.BA;

public class callark {

   
        System.loadLibrary("libarkactivity");
   Bundle b = new Bundle();
      b.putString("name", (position < 0) ? "" : folderList.get(position));
      b.putString("filename", (position < 0) ? null : filenameList.get(position));
      b.putString("directory", baseDirectory);
      intent.putExtras(b);
       return null;
    }
}

Like I mentioned, I am not a Java developer so this is a bit foreign to me. But basically I need to pass the arguments for name, filename and directory to that .SO app. Is that how I would do it?

Also, lets say that in some way what I said above makes sense, how do I expose it to B4A and run that .so app from within my B4A App? I hope all this is making sense for you guys. I know its a sort of loaded question/problem. Thanks.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As agraham and Erel suggest, it is not a simple matter. You first need to expose the library to java via the ndk, which I can tell you from personal experience, is not easy. Then you can expose the library to B4A.

If you do not know Java and C/C++ well it will be a very big learning curve.

-------------------
Sent via Tapatalk
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Ok then. Here is another approach to it then, I suppose.. Is there anyway I can include the app by having it compiled to an .apk and then include that .apk(Or the contents of it) and install it privately via my app(Without root)?

EDIT:

I believe the class has been exposed. Steve, I have the source code available for the app. Can I email you and Erel and see how I can access it from my app? It might actually be easier than I am making it because the app can install on its own and I am able to call and send arguements to it successfully from my app. I am just trying to make it as though it is part of my own app rather than having to have the user install it first and then run my app.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As I intimated, I am not an expert with the NDK. If you have a workable solution using intents I would go for that. I can't search for it now as I am not at my PC, but I'm sure I've seen a post on installing multiple apps which could be the way to go.

-------------------
Sent via Tapatalk
 
Upvote 0

timwil

Active Member
Licensed User
Longtime User
Now that we have inline Java in the latest version is it any easier to access a .so library?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…