Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLC + realm Library conflicts #1640

Closed
mjliu opened this issue Oct 22, 2015 · 22 comments
Closed

VLC + realm Library conflicts #1640

mjliu opened this issue Oct 22, 2015 · 22 comments
Labels

Comments

@mjliu
Copy link

@mjliu mjliu commented Oct 22, 2015

@beeender
use realm + VLC ,some devices crash. the error message :

org.videolan.vlc E/VLC/LibVLC﹕ Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.videolan.vlc-2/base.apk"],nativeLibraryDirectories=[/data/app/org.videolan.vlc-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libvlcjni.so"

VLC
336787fb-bf1b-4fbe-8e16-75c991621f5e

@cwangzh
Copy link

@cwangzh cwangzh commented Oct 22, 2015

I also want to know

@beeender
Copy link
Contributor

@beeender beeender commented Oct 22, 2015

@mjliu

  1. Which devices have this issue? Only arm64 chipset devices? What are the Android version of those devices?
  2. Which Realm version are you using?
  3. Does VLC lib have so files for all kinds of platforms?
  4. How did you load the vlc so file and when? Before the first time init Realm or after?
  5. Can you reproduce this issue?
@cwangzh
Copy link

@cwangzh cwangzh commented Oct 22, 2015

1.samsung s6 、huawei p8 and so on. Only arm64 chipset devices! above Android 5.0 .
2.0.81.1
3.Yes
https://wiki.videolan.org/AndroidCompile/#Devices
Devices
Find the ABI for the target device.
For a normal (2012-2015 consumer phone or tablet) device (e.g. Cortex-A8 or Cortex-A9)
armeabi-v7a
For a Tegra2 device (no NEON)
armeabi-v7a
For an ARMv6 device
armeabi
For an ARMv6 device that does not support FPU
armeabi-nofpu
For an ARMv5 device or the Android Emulator
armeabi-v5
For a x86 device (e.g. Android-x86, Google TV, Logitech TV, Android x86 smartphones, etc)
x86
For a MIPS device (i.e. Ainol Novo tablets):
mips
This value must be passed to the compile.sh script

4.before

5.Yes,Each time will now

@beeender

@beeender
Copy link
Contributor

@beeender beeender commented Oct 22, 2015

@cwangkkb @mjliu I think the problem is vlc doesn't supply a arm64 so file. In this situation, ASOP should just copy Realm's arm64 so and fallback to copy vlc's armeabi-v7a to app's lib directory.

can you please list all the files recursively in the phone's /data/app/org.videolan.vlc-2/lib/ directory which has this problem? It seems to be an AOSP bug...

@dalinaum
Copy link
Contributor

@dalinaum dalinaum commented Oct 22, 2015

Hello @cwangkkb @mjliu

I just built vlc. There is no aarch64 (arm64) so files.

I think you might encounter Can't load vlcjni library: java.lang.UnsatisfiedLinkError without Realm. Did you run your app on arm64 devices before?

$ find . -name "*.so"
./android-libs/arm-linux-androideabi/libbinder.so
./android-libs/arm-linux-androideabi/libcutils.so
./android-libs/arm-linux-androideabi/libhardware.so
./android-libs/arm-linux-androideabi/libmedia.so
./android-libs/arm-linux-androideabi/libstagefright.so
./android-libs/arm-linux-androideabi/libui.so
./android-libs/arm-linux-androideabi/libutils.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libanw.10.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libanw.13.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libanw.14.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libanw.18.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libanw.21.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libiomx.10.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libiomx.13.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libiomx.14.so
./libvlc/build/intermediates/bundles/release/jni/armeabi-v7a/libvlcjni.so
./libvlc/jni/libs/armeabi-v7a/libanw.10.so
./libvlc/jni/libs/armeabi-v7a/libanw.13.so
./libvlc/jni/libs/armeabi-v7a/libanw.14.so
./libvlc/jni/libs/armeabi-v7a/libanw.18.so
./libvlc/jni/libs/armeabi-v7a/libanw.21.so
./libvlc/jni/libs/armeabi-v7a/libiomx.10.so
./libvlc/jni/libs/armeabi-v7a/libiomx.13.so
./libvlc/jni/libs/armeabi-v7a/libiomx.14.so
./libvlc/jni/libs/armeabi-v7a/libvlcjni.so
./libvlc/jni/obj/local/armeabi-v7a/libanw.10.so
./libvlc/jni/obj/local/armeabi-v7a/libanw.13.so
./libvlc/jni/obj/local/armeabi-v7a/libanw.14.so
./libvlc/jni/obj/local/armeabi-v7a/libanw.18.so
./libvlc/jni/obj/local/armeabi-v7a/libanw.21.so
./libvlc/jni/obj/local/armeabi-v7a/libiomx.10.so
./libvlc/jni/obj/local/armeabi-v7a/libiomx.13.so
./libvlc/jni/obj/local/armeabi-v7a/libiomx.14.so
./libvlc/jni/obj/local/armeabi-v7a/libvlcjni.so
./vlc/contrib/arm-linux-androideabi/lib/preloadable_libiconv.so
./vlc/contrib/contrib-android-arm-linux-androideabi/iconv/preload/.libs/libiconv.so
./vlc/contrib/contrib-android-arm-linux-androideabi/iconv/preload/preloadable_libiconv.so
./vlc/extras/tools/cmake/Source/kwsys/libcmsysTestDynload.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libanw.10.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libanw.13.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libanw.14.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libanw.18.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libanw.21.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libiomx.10.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libiomx.13.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libiomx.14.so
./vlc-android/build/intermediates/exploded-aar/vlc-android/libvlc/unspecified/jni/armeabi-v7a/libvlcjni.so
@mjliu
Copy link
Author

@mjliu mjliu commented Oct 22, 2015

@dalinaum
without realm the VLC is ok. these devices have no that error

@cwangzh
Copy link

@cwangzh cwangzh commented Oct 22, 2015

@dalinaum
I run my app on arm64 devices before without Realm,hasn't problem.
after add realm jar lead to Can't load vlcjni library: java.lang.UnsatisfiedLinkError !

Vlc is no aarch64 (arm64) so files.
I run his demo normal. but add realm throw exceptions!!

Can you try it?

@mjliu
Copy link
Author

@mjliu mjliu commented Oct 22, 2015

@beeender
I can fetch realm's arm64 so and add this to the vlc anrmeabi-v7a .
but I don't know how to build a realm Jar without arm64 so . there has error multiple-dex

@beeender
Copy link
Contributor

@beeender beeender commented Oct 22, 2015

@mjliu
I think there is a bug in AOSP, the system failed to fall back to choose a non-64bit version of vlc when other so libs do have arm64 version.

See doc here:
https://realm.io/docs/java/latest/#couldnt-load-librealm-jniso Doc updated.

Simply exclude the .so you don't want in gradle like:

android {
    //...
    packagingOptions {
        exclude "lib/arm64-v8a/librealm-jni.so"
    }
    //...
}

----UPDATED Nov.17th, NO NEED TO USE BELOW----
One solution is, you can remove the Realm's arm64 so from your apk file and try again. Then the system will just choose non-arm64 so for both, vlc and Realm.

To build realm without arm64 so, just modify the realm-jni/build.gradle as

def targets = [
    new Target( name:'arm', jniFolder:'armeabi', toolchain:toolchains.find{it.name == 'arm'}, cflags:[ '-mthumb' ] ),
    new Target( name:'arm-v7a', jniFolder:'armeabi-v7a', toolchain:toolchains.find{it.name == 'arm'}, cflags:[ '-mthumb', '-march=armv7-a', '-mfloat-abi=softfp', '-mfpu=vfpv3-d16' ] ),
    //new Target( name:'arm64', jniFolder:'arm64-v8a', toolchain:toolchains.find{it.name == 'arm64'}, cflags:[] ),
    new Target( name:'mips', jniFolder:'mips', toolchain:toolchains.find{it.name == 'mips'}, cflags:[] ),
    new Target( name:'x86', jniFolder:'x86', toolchain:toolchains.find{it.name == 'x86'}, cflags:[] ),
    new Target( name:'x86_64', jniFolder:'x86_64', toolchain:toolchains.find{it.name == 'x86_64'}, cflags:[] )
]

Then run ./gradlew androidJar

@kneth
Copy link
Member

@kneth kneth commented Oct 22, 2015

@mjliu Can you confirm that solution proposed by @beeender works for you?

@kneth kneth mentioned this issue Oct 22, 2015
3 of 4 tasks complete
@mjliu
Copy link
Author

@mjliu mjliu commented Oct 22, 2015

@kneth
building realm jar. the net is too slow

@mjliu
Copy link
Author

@mjliu mjliu commented Oct 22, 2015

@beeender @kneth
this issue is resolved by @beeender 's solution.
thanks

we delete the x64 so.
1、what the impact of app without the realm x64 ?
2、have some other hidden troubles ?

@beeender
Copy link
Contributor

@beeender beeender commented Oct 22, 2015

@mjliu

  1. It might have a slight performance penalty by running 32bit native code on 64bit platform.
  2. Unless there is a system bug in 32bit lib on 64 bit system...
@cmelchior
Copy link
Contributor

@cmelchior cmelchior commented Oct 22, 2015

We should consider adding a section about this to our website. This problem as popped up quite a few times already.

@leolxmy
Copy link

@leolxmy leolxmy commented Oct 28, 2015

@mjliu Have you solved it?

@mjliu
Copy link
Author

@mjliu mjliu commented Oct 28, 2015

@leolxmy
Yes have solved

@leolxmy
Copy link

@leolxmy leolxmy commented Oct 28, 2015

How to solve?

@leolxmy
Copy link

@leolxmy leolxmy commented Oct 28, 2015

@mjliu How to solve?

@mjliu
Copy link
Author

@mjliu mjliu commented Oct 28, 2015

@leolxmy

To build realm without arm64 so, just
modify the realm-jni/build.gradle as

def targets = [
new Target( name:'arm', jniFolder:'armeabi', toolchain:toolchains.find{it.name == 'arm'}, cflags:[ '-mthumb' ] ),
new Target( name:'arm-v7a', jniFolder:'armeabi-v7a', toolchain:toolchains.find{it.name == 'arm'}, cflags:[ '-mthumb', '-march=armv7-a', '-mfloat-abi=softfp', '-mfpu=vfpv3-d16' ] ),
//new Target( name:'arm64', jniFolder:'arm64-v8a', toolchain:toolchains.find{it.name == 'arm64'}, cflags:[] ),
new Target( name:'mips', jniFolder:'mips', toolchain:toolchains.find{it.name == 'mips'}, cflags:[] ),
new Target( name:'x86', jniFolder:'x86', toolchain:toolchains.find{it.name == 'x86'}, cflags:[] ),
new Target( name:'x86_64', jniFolder:'x86_64', toolchain:toolchains.find{it.name == 'x86_64'}, cflags:[] )
]
Then run ./gradlew androidJar

@leolxmy
Copy link

@leolxmy leolxmy commented Oct 28, 2015

@mjliu Can you give me a demo? I'm not quite understand

@beeender
Copy link
Contributor

@beeender beeender commented Oct 28, 2015

@leolxmy Or you can just use our released jar file, and open it with normal archive tools, remove the arm64 directory. jar file is just a zip file.

@beeender
Copy link
Contributor

@beeender beeender commented Nov 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.