2

I want to get the native lib path from data for my app that will be installed in the system, I have tried this code:

String libPath = "/data/data/" + packageName + "/lib/" + libName+".so";
System.load(libPath);

But it gives this error:

java.lang.UnsatisfiedLinkError: dlopen failed: library /data/data/xxxx/lib/lib.so not found

I tried to not hardcod it using

String libraryPath = context.getFilesDir().getParentFile().getPath() + "/lib/"+libname+".so";
System.load(libraryPath);

but the same error was shown, if I use this code :

String libPath = context.getApplicationInfo().nativeLibraryDir +libname+".so";
System.load(libPath);

The app will try to get native lib from system/app and the same error is shown, Can anybody help to force get native lib from data? Maybe something like this

context.getApplicationInfo().nativeLibraryDir

But force to data, not system, because when I try to show that libpath in log (when I try installed in data), it will show

/data/app/apppackage-1/lib/arm/libname.so

There is a number after package name sometimes -1, sometimes -2.

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Redturbo
  • 1,563
  • 8
  • 22
  • 34
  • Seems your target SDK is 23 . Please refer this question http://stackoverflow.com/questions/32845956/android-m-crash-java-lang-unsatisfiedlinkerror-dlopen-failed/32846340#32846340 , It will solve your issue – dex Nov 18 '15 at 04:44
  • Try this String libPath = context.getApplicationInfo().nativeLibraryDir +File.separator +libname+".so"; – dex Nov 18 '15 at 04:59
  • that's not worked, I still got same error @dex – Redturbo Nov 18 '15 at 13:19
  • Could you solve your problem? My application has a library and is installed in the system/priv-app/ folder. And when you start, these libraries are in the /System/lib/ folder. Here is my question http://clc.am/0sZpqg – DuosDuo Mar 16 '19 at 10:32

0 Answers0