I'm developing a native application using C/C++.
I need to use name resolution service.
Making JNI calls is an option.
Using an external native library is another option.
However, I'm thinking about the probability of a third option.
As noted here, on devices running Android 10 and higher, this service is provided with a native library (libnetd_resolv.so).
This means, functions that I need rest in this library and I can confirm that.
My question is, can I use this library dynamically and get name resolution service?
I know that Android doesn't allow applications to use system libraries but what if I download this shared object and distribute with my application*, does it work?
If it doesn't, is there a future plan for this to work?
I'm asking because it is so weird to me that I need a function, it resides in my hands, but I have to make JNI calls in order to use it.
* When I embed the shared object in my application, there may be some compatibility problems when new updates are made to the shared object but that's not the point for me, if it works for one Android release it's ok.
Before attempting to add in a third-party library, do check if the existing Android NDK Networking APIs support your use case.
Do be aware of which versions of Android any particular API is supported.
Related
I have an existing Android App that we now want to leverage as an SDK (or whatever is the equivalent on Android, a library?), so that the application could be included in another Android App as a library.
The concept is that we provide a "wrapper" class that customers make calls to, which would then interface with the existing code to do the functions, display stuff and do the work our App generally does.
My hope is to be able to not have to move code around and just create a wrapper/SDK/Library interface which I can just build differently in gradle, and the result of that (a Library object?) would be given to the customer to include into their App.
Hope I am making sense. If you need more info I can give a high level example of what the App is doing.
Is there any way to limit Android NDK Library to the Specific JAVA Application ? I would like to prevent programmers from using my lib in another applications.
EDIT
I'm building a shared library that will be used in another application by user(another programmer).
EDIT 2
this library also include a java library that interact with the native library via JNI.
I would like to prevent programmers from using my lib in another applications.
... presumably for copy-protection of some sort.
You didn't say whether the "permitted" application is built by you or by someone else.
If the former, linking your library statically into the application will make it very hard to reuse that library elsewhere.
If the latter, you could use some techniques, such as looking in /proc/self/exe to find application name from within the library and exit if what you see there is not what you allow, but
such techniques will likely cause grief to your customers, and
will increase your support load (when they misfire under legitimate conditions), and
will be trivially bypassed by a moderately sophisticated adversary.
Which is to say that generally that's a waste of time.
I need to create an API library for Android and iOS. I have experience working with Android projects, but zero experties in iOS. I was wondering if I could create a Project library in Xamarin that compiles as a JAR for Android and as an... I-don't-know-which-type for iOS.
No, that isn't possible. Depending on what you are trying to accomplish there may be alternatives. If you are trying to make a library that can be used by others you could make it a Xamarin component - there is a component store you could put it on if you want it to be generally available, otherwise you can use any normal means of source or object distribution.
If you need to interact with a native app/library then you could make the C# code the "owner" of it and have it call into the native code. This works for both IOs and Android (and is used to work with e.g the play services from google).
No, it is unfortunately not possible to do that.
It seems to me that what you need is a Portable Class Library also known as PCL. It allows you to create a project which can be referenced by all Xamarin supported platforms (such as iOs and Android). There are obviously limitations to the approach like not being able to reference platform specific libraries but in your case (of writing an API) it should suffice.
You can read more in this link
Good Luck!
I am creating an app showing local events for android. I was hoping to use the Eventful API, since that came with its own java-based client library. However, I'm not sure if it's fit for Android, since I know a lot of these java based client libraries use stuff Android doesn't support.
So, does anybody know if it works?
My entire project is available # github if you want to check it out for yourself.
The API is found here.
Android does not have have issues with Java client libraries. It is build on top of standard Java, and can use all of the framework features.
Furthermore, it looks like this API offers a RESTful interface, which is for sure supported by Android.
Bottom line, I do think you can use this API in Android without issue.
I'd say the easiest way is to compile and run an application that embeds the library and tests a few methods.
Typically, you may have issues with the way the networking is handled. There are 2 main ways in android to do HTTP, the Java and the Apache way, I think the Java URL API is fully supported and very close to the actual Java version, but the Apache has some hidden differences.
The main risks you'll have are A/ that it uses classes or packages that are not present on Android. B/ that a class does not behave as expected, which does happen from time to time, as the Android implementation is entirely specific.
Apparently you have already tried to run an android app with the library included? Did you encounter a specific error? If you, can you post the stacktrace?
Presently in my Android system, I have developed a native library to communicate
with a connected media device over linux driver and we are accessing it from an
apk application via the Java native interface. This has been working fine till
now.
But we also have another application which needs to access the same native library
in parallel with the first application. As expected, because of the different data
section for the linked native library in the new application this approach is not
working.
To subvert this, we though of writing a new service/application which will be linked
with the native library and other applications access the APIs using binder calls to
this new service/application.
My question is:
Is this new approach feasible? Can someone help me with a better approach.
If yes, then we also need to return buffers in the API and some of the APIs are
callbacks. Can these types of functions be handled using the binder interface?
Thanks,
Ashutosh
Build an external library in a jar that provides the higher level API which in turn accesses the native library. Then use this jar library as any other lib. You may have to check how to put the .so file into the jar file to have a single library file.
I believe that the service approach is exactly how opencv achieves this.... specifically, OpenCV has a manager in thr app store. You can develop an app that implements BaseLoaderCallback, which gets the .so library from this manager. Behind the scenes, this uses a Service, ServiveConnection, and aidl to get the library... if memory serves me right.
Update...
Now that i think about it, i think OpenCV manager might just be passing the path to the library, which can then be loaded with the System.load command, which accepts the library path.