13538

Adding “.so” library to my android studio project

I am having issues when i try to add a spatialite database to my android studio projet.I followed this tutorial https://www.gaia-gis.it/fossil/libspatialite/wiki?name=spatialite-android-tutorial , as mentioned i added two folders to my project :

<ol> <li>

the native spatialite libraries: they are places in a folder named libs in my App directory and contains several folders for different platforms that hold the main library, called libspatialite.so

</li> <li>

the basic API classes, contained in the jsqlite package

</li> </ol>

Despite this ,i am getting this error :

11-13 13:52:17.358 1853-1853/liara.geodatamining W/System.err﹕ Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: Couldn't load proj from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/liara.geodatamining-2.apk"],nativeLibraryDirectories=[/data/app-lib/liara.geodatamining-2, /system/lib]]]: findLibrary returned null 11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ No implementation found for native Ljsqlite/Database;.internal_init:()V 11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Ljsqlite/Database; 11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2d19b20) 11-13 13:52:17.358 1853-1853/liara.geodatamining E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: liara.geodatamining, PID: 1853 java.lang.UnsatisfiedLinkError: Native method not found: jsqlite.Database.internal_init:()V at jsqlite.Database.internal_init(Native Method) at jsqlite.Database.<clinit>(Database.java:951) at liara.geodatamining.map.onCreate(map.java:116) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)

Am i missing something ?

Answer1:

This sounds a lot like you haven't included the appropriate version of the NDK for your emulator. Per the Android docs, the following platforms support Android NDK

    <li>ARM</li> <li>ARM-NEON</li> <li>x86</li> <li>MIPS </li> </ul>

    The most common by far for real devices is ARM (armeabi-v7a). In fact, it's probably almost no loss to not include anything except for this for a published build. But the emulators often work off of x86. I know I have a NDK file for x86 that I remove every time I'm ready to build for release, and re-add when I want to use my desktop emulator.

    Answer2:

    if you're only using .so files and not compiling any C/C++ sources yourself, you don't need the NDK.

    With Android Studio, the place where you drop .so files isn't the same than with eclipse. Now it's inside jniLibs/<ABI> where ABI can be armeabi, armeabi-v7a, x86, x86_64, mips, mips64, arm64-v8a.

    You can check that your .so files are properly integrated by opening your APK as a zip file and simply checking that your .so files are inside lib/<abi> folders.

Recommend

  • Android nativedriver, starting an app with istrumentation
  • RuntimeException : Didn't find class on path: DexPathList
  • Native library not loaded from cordova apk
  • Adapting dependencies after downgrading Google Play Services
  • Android app crashes instantly with “Didn't find class {hash}.MainApplication” [duplicate]
  • Strategies to secure a WCF service, returning Json data requested by jQuery
  • How to get past the “total_rows” when parsing JSON from CouchDB
  • java.lang.NoClassDefFound error javax Gmail API
  • Defining variable by logical subseting on time interval in data.table
  • Enable Bootstrap Intellisense using Angular 4 in WebStorm
  • Partial specialization of a class template in derived class affects base class
  • CoreData basics – to-many relationship array data
  • Eloquent Relationship on Partial Match
  • Wrapping text in spinner android
  • How to resolve permission denied maybe missing internet permission?
  • XMLBeans Duplicate Class and Class Not Found Errors
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Counter field in MS Access, how to generate?
  • Is there a amazon webstore API for customers?
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to extract text from Word files using C#?
  • Validaiting emails with Net.Mail MailAddress
  • vba code to select only visible cells in specific column except heading
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Why winpcap requires both .lib and .dll to run?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Proper folder structure for lots of source files
  • KeystoneJS: Relationships in Admin UI not updating
  • trying to dynamically update Highchart column chart but series undefined
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • embed rChart in Markdown
  • How does Linux kernel interrupt the application?
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app