简体   繁体   English

JNI应用程式发生错误

[英]Error with JNI app

I have compiled .so library for app and java app app for calling methods from this library. 我已经为应用程序和Java应用程序应用程序编译了.so库,以便从该库中调用方法。 Library compiled for ARMv7 and app work fine on real device (Nexus 4). 为ARMv7和应用程序编译的库在真实设备(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. 在Eclipse中开发的Android应用。 In root directory, I have "libs" directory with folders which names of architectures. 在根目录中,我有“ libs”目录,其中包含架构名称的文件夹。

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. NDK-10c,设备上的Android-5,在模拟器上-4.2.2,适用于Android App的minSdkVersion = 8。

PS Compile lib with next configure file: PS编译带有下一个配置文件的库:

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. 获取错误,因为模拟器使用x86体系结构。 Using lib for x86, it's work fine 使用lib for x86可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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