how to load libandroid_runtime

2020-07-23 05:54发布

问题:

I'm working on a project that gets compiled into a JAR and then deployed using javaws. In one of my classes, I need to load the libandroid_runtime.so found in directory /system/lib/ on the device.

How do I do this?

System.load("libandroid_runtime")throws java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: libandroid_runtime

System.loadLibrary("/system/lib/libandroid_runtime.so") throws java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: /system/lib/libandroid_runtime.so.

System.loadLibrary("android_runtime"); throws java.lang.UnsatisfiedLinkError: no android_runtime in java.library.path

thanks!

回答1:

I'm working on a project that gets compiled into a JAR and then deployed using javaws

Android does not use Java Web Start.

In one of my classes, I need to load the libandroid_runtime.so found in directory /system/lib/ on the device.

That is not possible. You do not have read access to /system.



回答2:

System.loadLibrary("android_runtime"); requires the library libandroid_runtime.so to be in /data/data/{app}/lib while System.load("/system/lib/libandroid_runtime.so"); requires the full path.

So none of your calls is correct. The answer is System.load("/system/lib/libandroid_runtime.so");