1

The Error I will get is

Couldn't load json from loader dalvik.system.PathClassLoader[DexPathList[dexElements=[zip file "/data/app/com.uei.tools.ndktest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.uei.tools.ndktest-1, /vendor/lib, /system/lib]]]: findLibrary returned null

I created a zip file of all .so files and i added into libs folder under app folder i added jar dependency from Module settings dependency.

All serch resulted in sample code of old versions of android studio but there is no sample for Android studio 0.8.6 beta

Aravinda
  • 11
  • 1
  • 2
  • "I created a zip file of all .so files" perhaps that's an oddball feature of Android Studio, but normally you would place the *individual* .so files in the appropriate ABI subdirectory of the libs directory. – Chris Stratton Sep 08 '14 at 15:31

1 Answers1

2

With Android Studio 0.8.x, you can directly add your prebuilt .so files under a jniLibs folder, inside folders corresponding to each ABIs. For example:

  • app/src/main/jniLibs/armeabi-v7a/libMyLib.so
  • app/src/main/jniLibs/x86/libMyLib.so

You can find up-to-date samples at the bottom of this page: http://tools.android.com/tech-docs/new-build-system#sites-attachments

ph0b
  • 14,353
  • 4
  • 43
  • 41
  • When i create a project the **jniLibs** directory will not getting created if i create it manually this will not work. How to create jniLibs foloder under main directory? – Aravinda Sep 09 '14 at 10:57
  • The Samples in the link are for old gradle release they are up to 0.9 version but the current version is 2.0 how to continue? – Aravinda Sep 09 '14 at 11:08
  • 1
    Current version isn't 2.0. Android Studio supports up to gradle 1.12 and the samples are compatible with this version. You have to create the jniLibs directory manually from Android Studio: right click on your sources folder->new folder – ph0b Sep 09 '14 at 11:24
  • I added a folder called jniLibs after that program worked but the library dint loaded the command Systm.loadlibrary("some_library") return undefined and program end and shows unfortunatily program stopped. – Aravinda Sep 10 '14 at 06:50
  • You can look at what gets packaged inside your APK by opening this APK as a zip file. The libs inside jniLibs should be included inside `lib` folder. If that's not the case, please post your build.gradle files and your project structure (list of directories, modules..) – ph0b Sep 11 '14 at 08:20
  • It is included in the library folder. The problem is I have a file called libjson.so. If i call System.loadLibrary("json"); it returns Undefinded when i call method of library libjson.so the applications closes and even if i have method in try catch block it doesn't catches any exception. – Aravinda Sep 12 '14 at 11:07
  • If libjson.so sucessfully loads but calls to its methods are crashing, maybe the packagename of your Json library has changed ? it's usually hardcoded in the .so file so you shouldn't modify it. Also, what are the errors and warnings you're getting now in the logcat when loading the lib and calling methods ? – ph0b Sep 15 '14 at 09:13