loading library (.so file) in android [duplicate] - android

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Creating a product SDK: How do I add a native lib (.SO) and a jar with the SDK I am creating?
I'm trying to use com.android.SystemClock in an app, which calls a native method. I need to load the library that this native method belongs to (i.e. System.loadLibrary(...)). The method is defined in the file: frameworks/base/core/jni/android_os_SystemClock.cpp. How do I figure out which library this belongs to and load it as well?

Inspect the make files and find out what libs it builds. Look for LOCAL_MODULE. That said, it is probably in libandroid_runtime.so.
And then again, if it is not part of the public SDK, you shouldn't be using it. It may change, break, not work on some devices, etc.

Related

NativeScript : Use platform specific native library without a multi-platform plugin?

We're trying to use ArcGIS's Android Runtime SDK in NativeScript (it has no nativescript plugin) but we have accessed that rewriting the whole library as a multi-platform plugin would take too much time.
My question is, how can we utilize the native library directly but only the android version of it?
This is the library: https://developers.arcgis.com/android/latest/api-reference/reference/packages.html
Also, is it possible to use it without a custom UI plugin? I don't understand how to add the mapView to the app .xml
For example, in their AndroidStudio tutorial they mention the following steps and I'm not sure how to translate them to NativeScript
Source : https://developers.arcgis.com/android/latest/guide/develop-your-first-map-app.htm
I'm not quite sure what you mean by re-writing the whole library, you never have to do that.
Plugins are being written to wrap the native library with simple user friendly JS api / methods, it necessarily need not to be cross (or multi) platform either.
You may even directly access any third party library within your project as soon you mark them as dependency in your app gradle file.
Here is how you access native apis.
For instance if you want to create an instance of LocatorTask, this should work once you add the library as dependency in your NativeScript project.
const locatorTask = com.esri.arcgisruntime.tasks.geocode.LocatorTask("URI_HERE");
locatorTask.loadAsync();

How to show git-describe in React Native app?

I generally like to automatically bake-in the results of a git describe --always --dirty in any website, app, etc I am developing so that I can easily trace behaviors. Right now, I can't figure out a way to get this in a React Native app.
I am using Android, but am certainly looking for a solution to both Android and iOS.
I found a way using a mix of other existing answers:
Call git-describe during the build to access from gradle
Call PackageManager to access the gradle config from Java
Then use a React NativeModule in Java to access from JS
Update (3 years later): Here's a minimal diff that shows how to implement in Android.

Android N: how to use system library

In my current code till android 6 (API-23) i was able to open libjavacore.so
libcrypto.so and libwebviewchromium.so using dlopen() function.
but in Android N access of private library are restricted by Google. So any one can help me how to load these libraries.
Your app directly accesses private platform libraries. You should update your app to include its own copy of those libraries or use the public NDK APIs.
How to create copy of those library?
Seems like there is no way to workaround it correctly. In general you should write you own dynamic linker, that loads required libraries (or look to crazy_linker from NDK). Then you should perform symbol lookup manually. If library is already loaded by the system - you need only the latter.
Anyway such approach is fragile and doesn't guarantee that such tricks won't be disabled in the future. So better is to avoid using of private libraries and use your own versions or public NDK API instead.

Object recognition with android using OpenCV library [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Where do I start learning about image processing and object recognition?
Is there any best way for implemeting Object Recognition in android?
I tried to implement object recognition(Face tracking) in my project using OpenCV library, But I have a problem with openCV when I run this application on my device it require to install OpenCV Manager in your device.
I just wanted to know is there any way to do object recognition without install any external application or supporting file in device.
Or you could try the FaceDetector class. Its available since API Level 1.
Try attach native libraries for OpenCV to your project and use OpenCVLoader.initDebug(); to initialization.

Android library engineering [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Intro: I have a native library (C++) with Java (JNI) wrapper. The library engine is cpu intensive, we don't want more than one app linking this lib to be running at the same time, and complex objects should be returned by the lib engine.
The question: What is the best way to engineer such an Android library?
So far, I could find just find 2 valuable examples: OpenCV manager and Connectbot ssh-agent.
I can think of a few solutions:
Solution 1: Make a (bound or AIDL) service that wraps the library functionality. (should the service run in its own space? or in the space of the application that links to it? how can the native lib be loaded if it's in a different app space(System.load("/data/data/com.company.myLib/lib.so")). How to return complex objects in AIDL?). This should be the Connectbot way.
Solution 2: Divide the lib into 2 components:
A standalone package which keeps the native libs + a manager service
An android lib-project which only contains Java wrappers which users can use to build their apps.
This should be the OpenCV manager way. I don't know exactly the details, but this way one does not need a service to interface with and can just import com.company.myLib.LibWrapper. On the other side the LibWrapper class should perform System.load("/data/data/com.company.myLib/lib.so"). Correct?
I would personally go for solution 2. Unfortunately Android is a new land and there are not many models yet on how to develop a library. Is there any other/better solutions? Is there other considerations to make?
Consider the following scheme: you build an "empty" app that contains no activities, no settings - only the manifest, the icon for "manage apps" list and the native lib that is installed by the system in /data/data/package/lib directory.
This native library may, but doesn't have to expose JNI functions. In a typical situation, this lib will be a straightforward port of an opensource LGPL library - e.g. libdmtx.so.
The "client" apps will call loadLibrary() for the "external" lib, and after that it will call the usual load() for its JNI wrapper. This lib has the only purpose to translate Java methods to the public C APIs of the external lib.
The JNI wrapper and the corresponding Java class may be distributed as a .jar or as sources, they are not bound by LGPL license of the external lib.
Such scheme is, IMHO, the only way to ensure LGPL compliance on Android: anybody can recompile the "external" lib from the open source, package it as an "empty" app and install it on their device.
Regarding your concern about concurrent access to the lib, I actually doubt that it is so important: the high end devices have four cores more powerful each than one core on cheaper devices. OTOH, it's easy to use Linux synchronisation methods, e.g. named pipes, to keep track of active instances.

Categories

Resources