Using ARMv7 and ARM library in the same Android App - android

I am struggling with using Dropbox (Sync API) and Andengine in the same android app. Both are using native libraries and, as far as I know, Andengine is developed for ARMv7a and Dropbox for ARM systems. Running each part of the application on its own, everything works fine. However, combining both parts results in a: java.lang.UnsatisfiedLinkError: Couldn't load DropboxSync: findLibrary returned null.
It seems that only the armeabi-v7a folder is checked for the library as soon as this folder is present? However, the libDropboxSync.so is only located in the armeabi folder.
Everything is tested with a Nexus S running Android 4.1.2.
Thanks in advance,
Stefan

From $NDK/docs/CPU-ARCH-ABIS.html: if primary-abi is found secondary won't be scanned.
III.3. Automatic extraction of native code at install time:
-----------------------------------------------------------
When installing an application, the package manager service will scan
the .apk and look for any shared library of the form:
lib/<primary-abi>/lib<name>.so
If one is found, then it is copied under $APPDIR/lib/lib<name>.so,
where $APPDIR corresponds to the application's specific data directory.
If none is found, and a secondary ABI is defined, the service will
then scan for shared libraries of the form:
You can check this by;
$ adb shell getprop|grep abi
[ro.product.cpu.abi2]: [armeabi]
[ro.product.cpu.abi]: [armeabi-v7a]
as you can see primary abi is more specific then the secondary one.
Solution-wise you can move armv5 library under armv7-a. It should work, but it will be only visible to such devices under Google Play.

Check out the 3rd and 4th point
Within Android Studio, switch to the "project view".
From the libs directory in the downloaded SDK, drag dropbox-sync-sdk-android.jar into your project's app/libs directory.
Right-click on dropbox-sync-sdk-android.jar and choose "Add as library". Click "OK" on the dialog that appears.
Make a new directory in your project under app/src/main called jniLibs. From the SDK, drag armeabi, armeabi-v7a, mips, and x86 into
the new jniLibs directory.

Related

Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList couldn't find "libvlcjni.so"

After extending support for Android 6.0+.
The app is getting crash while playing video using VLC-SDK.
Previously we have make changes in SDK library a little bit as per our project need. Hence can't make changes in vlc-SDK.
I have tried the solutions as below:
Adding ABI filters.
Add gradle.properties file in project.
Add android.useDeprecatedNdk=true; in gradle.properties
Adding abi filters in build.gradle.
This means that the compiled abi binary specific for the device being run on is not found in the APK. As a start check the APK in Android Studio using APK Analyzer (or just drag the APK from inside app/build/outputs/apk/ to the middle) and see within the lib/ folder the abi's that have been compiled. If your device abi is not listed within the lib/ folder, then that's the cause of your error and should do further checking like within the generated build files if it's missing (usually within .externalNative).

Android single so for different abis

I have library project with precompiled so files. I want to minimize size so I want to use "armeabi" .so file for all arm abi's. (i need only arm code). To do this I put in jnilibs only the armeabi folder with the .so file.
The problem rises when i try to test this:
I created a demo app that uses my library project, the google play says i don't have a compatible device for this app.
Is it possible to use the same so file for all arm architectures and maintaining the size (in library project) ?
I don't care about preformance

android native lib not installed with APK

I've made an android library project that uses some native libraries.
I've made the jni wrapper and put the native libs (.so) in the libs// folders. The native libs are compiled using cmake, for armeabi, armeabi-v7a, x86 and mips.
I export this project to a jar and put this jar into a "normal" android project. I then export this project to an apk and can see that my libs are bundles into it.
However, when i install the apk, the libs corresponding to the device are not copied into /data/data/com.my.app/lib and obviously, running the app complains about not finding the libs (UnsatisfiedLinkError).
I've search through SO and everywhere i can but found no answer that solved my case.
i'm using Eclipse, btw
Thanks for your help
UPDATE
OK, i've read the doc in the ndk and seen the examples, and unfortunately, i can't see the solution.
The ndk build the c code into shared libs and places them into the appropriated location in the project. But it doesn't generate anything that says that the libs must be installed with the apk.
My goal is to provide an android library (so a jar), that can be included within an android application. I don't see the real difference between what i'm doing (compile the c libs using cmake and package the jni and java compiled classes into a jar) and what is done with android.mk
If you see what i'm missing, feel free to tell me (even if its obvious).
thanks
UPDATE
i've made a dirty hack: in the libs folder of my application, i've put the jar file containing my classes and my native libs and a copy of the .so files for each arch. Suprise, the libs are no installed in /data/data/com.me.myapp/lib
It seems to confirm that it's a packaging problem.
I export this project to a jar and put this jar into a "normal"
android project. I then export this project to an apk and can see that
my libs are bundles into it.
The issue is that the Android packaging system doesn't handle with binary assets in JARs. For your application project to find and include the generated .so files, you need it to reference the library project as an 'Android library project':
Did you call ndk-build command?
See description below for details.
http://developer.android.com/tools/sdk/ndk/index.html
You can build the shared libraries for the sample apps by going into /samples// then calling the ndk-build command. The generated shared libraries will be located under /samples//libs/armeabi/ for (ARMv5TE machine code) and/or /samples//libs/armeabi-v7a/ for (ARMv7 machine code).

Should I expect worklight to create armeabi-v7a directory in Android project?

For a project I'm working on, we need to have an .so file submitted to the apps/[app]/android/native/libs/armeabi-v7a directory. When I did this, though, I got class not found errors... realized I need other libraries in armeabi-v7a similar to the libraries that Worklight puts in the armeabi directory (e.g. libopenssl_fips).
Should I "simply" copy those myself from apps/[app]/android/native/libs/armeabi to apps/[app]/android/native/libs/armeabi-v7a? Or is there something different I should be doing so that WL builds the apps/[app]/android/native/libs/armeabi-v7a directory with those libraries (e.g. libopenssl_fips) inside it?
Thanks,
Eric
You should place those files on your own in the location you've specified. Worklight will not do that.

Adding prebuilt library to android apk

I have built a dynamic library in android using android build system. This library provides jni interface for functions inside it. Now I want to include this library in an application (.apk). I am using eclipse for application development. Now, how can I use the prebuild dynamice library (.so) in my application ? I tried putting it in a lib folder in my application but it is not working.
Any pointers are appreciated.
I am not using ndk to build my .so.
Since you write 'so' I think you're using NDK. If you're using NDK I don't know the answer.
If you're using the "Java" SDK, then in your library project go to Properties -> Android, and Check "Is Library". In your "apk" project, go to Properties -> Android -> Add . And your Library project should be available.
Also, any Library added in the "Java Build Path" Menu (again, in project properties) should be available in the APK in the end.
I know it's slightly old, but have you checked in the built APK to see if your .so library is there? Should be in the libs/armeabi folder.
Also, your .so file should be in lib/armeabi folder in your eclipse solution. I'm guessing the armeabi bit depends on which processor your .so file is build for.
Also, I know that if your library isn't called lib[name].so, it won't get copied when the apk is installed on the device. So:
libfoo.so copies
foo.so doesn't copy
foo.so doesn't copy
Also, you can use DDMS (its a view in eclipse) and it's file explorer to see if it's been copied to your device. It should be under data/data/[packagename]/lib.
Hope this helps a bit!
Andy.
I hit this same problem while building Qiqqa for Android. Under your eclipse android project, make sure you have a libs directory (not that it is plural libS not singular lib). Inside that create the armeabi/etc subdirs with their respectibe .so files.
Then when you build, eclipse will automatically pick up this libs directory and create the corresponding lib in your apk. System.loadLibrary("XXX") will then resolve to libXXX.so on your correct architecture...
Cheers,
Jimme

Categories

Resources