简体   繁体   中英

Error with JNI app

I have compiled .so library for app and java app app for calling methods from this library. Library compiled for ARMv7 and app work fine on real device (Nexus 4). When i try to lauch this app on emulator, I get next error:

dlopen("/data/app-lib/com.opendesign.android-2/test_jni.so") failed: dlopen failed: cannot locate symbol "srand" referenced by "test_jni.so"...
WARNING: Could not load test*_jni.so

For load library, i have next code:

try {
            System.loadLibrary("test_architecture_jni");
        } catch (UnsatisfiedLinkError use) {
            try {
                System.loadLibrary("test_jni");
            } catch (UnsatisfiedLinkError use1) {
                Log.e("JNI", "WARNING: Could not load test*_jni.so");
            }

Android app developed in Eclipse. In root directory, I have "libs" directory with folders which names of architectures.

On real device work fine, but on emulator of this device - crash. NDK - 10c, Android on device - 5, On emulator - 4.2.2, minSdkVersion for Android App = 8.

PS Compile lib with next configure file:

mkdir -p Platforms/android_armeabi-v7a_r10c_mingw_x64dbg
export ANDROID_NDK_ROOT="/opt/android-ndk-r10c"
export ANDROID_NDK_BIN="toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin"
echo -e "all:\n\tcd Platforms/android_armeabi-v7a_r10c_mingw_x64dbg && make all\nclean:\n\tcd Platforms/android_armeabi-v7a_r10c_mingw_x64dbg && make clean\n" > Makefile
cd Platforms/android_armeabi-v7a_r10c_mingw_x64dbg
../../build/cmake/bin/cmake -G "Unix Makefiles" -D ODA_HAS_OPENGL=1 -D ODA_OPENGL_LIBS="GLESv1_CM" -D CMAKE_CXX_COMPILER_WORKS:INTERNAL=1 -D CMAKE_C_COMPILER_WORKS:INTERNAL=1 -D CMAKE_DETERMINE_CXX_ABI_COMPILED:INTERNAL=1 -D CMAKE_DETERMINE_C_ABI_COMPILED:INTERNAL=1 -D CMAKE_SYSTEM_NAME:STRING=gcc -D CMAKE_CROSSCOMPILING:INTERNAL=1 -D ODA_PLATFORM_LIBS:STRING="c;m;dl;gnustl_static" -D ODA_ANDROID_ARCH:STRING="armeabi-v7a" -D CMAKE_REQUIRED_LIBRARIES="-lc -lgnustl_static" -D CMAKE_CXX_STANDARD_LIBRARIES="-lc -lgnustl_static" -D ANDROID=TRUE -D ANDROID_NDK_CRYSTAX=FALSE -D ANDROID_NDK_GOOGLE=TRUE -D CMAKE_CXX_FLAGS:STRING="--sysroot=${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/ -Wno-psabi -fPIC -DANDROID_WCHAR -DANDROID_GOOGLE -DANDROID -DANDROID_NDK_NATIVE -I${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/usr/include  -I${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include -I${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I. -ffunction-sections -fexceptions -frtti -Wno-psabi -fPIC -Wl,--no-undefined" -D CMAKE_C_FLAGS:STRING="--sysroot=${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/ -Wno-psabi -DANDROID_WCHAR -DANDROID_GOOGLE -DANDROID -DANDROID_NDK_NATIVE -I${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/usr/include -ffunction-sections -fPIC -Wl,--no-undefined" -D CMAKE_CXX_COMPILER:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-g++.exe -D CMAKE_C_COMPILER:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-gcc.exe -D CMAKE_SHARED_LINKER_FLAGS:STRING="-L${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -L${ANDROID_NDK_ROOT}/sources/libs/armeabi-v7a -L${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/usr/lib  -Wl,-no-undefined,-dynamic-linker=/system/bin/linker,-rpath-link=${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/usr/lib -Wl,--no-undefined" -D CMAKE_AR:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-ar.exe -D CMAKE_LINKER:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-ld.exe -D CMAKE_LD:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-ld.exe -D CMAKE_NM:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-nm.exe -D CMAKE_OBJCOPY:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-objcopy.exe -D CMAKE_OBJDUMP:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-objdump.exe -D CMAKE_STRIP:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-strip.exe -D CMAKE_RANLIB:PATH=${ANDROID_NDK_ROOT}/${ANDROID_NDK_BIN}/arm-linux-androideabi-ranlib.exe -D CMAKE_MAKE_PROGRAM:PATH=/usr/bin/make -D CMAKE_LIB_PATH="${ANDROID_NDK_ROOT}/platforms/android-${ANDROID_PLATFORM}/arch-arm/usr/lib"  -D CMAKE_BUILD_TYPE=Debug -D CMAKE_CONFIGURATION_TYPES=Debug  ../../

Error getting, because emulator use x86 architecture. Using lib for x86, it's work fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM