OpenSSL JNI FAILURE:构建失败,异常

时间:2017-11-21 05:40:40

标签: android android-ndk openssl java-native-interface

我正在尝试构建JNI项目并使用openssl进行加密和解密。我得到了以下错误。这是什么意思?我们什么时候得到这样的错误?以及如何解决它?

失败:构建因异常而失败。

  • 出了什么问题: 任务':app:externalNativeBuildDebug'执行失败。
      

    构建命令失败。   执行进程C:\ android \ sdk \ cmake \ 3.6.4111459 \ bin \ cmake.exe时出错{--build C:\ SampleJni \ app.externalNativeBuild \ cmake \ debug \ armeabi-v7a --target native-lib }   [1/2]构建CXX对象CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o   [2/2]链接CXX共享库........ \ build \ intermediates \ cmake \ debug \ obj \ armeabi-v7a \ libnative-lib.so   失败:cmd.exe / C" cd。 &安培;&安培; C:\ android \ sdk \ ndk-bundle \ toolchains \ llvm \ prebuilt \ windows-x86_64 \ bin \ clang ++。exe --target = armv7-none-linux-androideabi --gcc-toolchain = C:/ android / sdk / ndk-bundle / toolchains / arm-linux-androideabi-4.9 / prebuilt / windows-x86_64 --sysroot = C:/ android / sdk / ndk-bundle / sysroot -fPIC -isystem C:/ android / sdk / ndk-bundle / sysroot / usr / include / arm-linux-androideabi -D__ANDROID_API __ = 14 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march = armv7-a -mfloat-abi = softfp -mfpu = vfpv3-d16 -fno-integrated-as -mthumb -Wa, - noexecstack -Wformat -Werror = format-security -O0 -fno-limit-debug-info -Wl, - exclude-libs,libgcc。 a --sysroot C:/ android / sdk / ndk-bundle / platforms / android-14 / arch-arm -Wl, - build-id -Wl, - warn-shared-textrel -Wl, - 致命警告-Wl, - fix-cortex-a8 -Wl, - no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname ,libnative-lib.so -o ........ \ build \ intermediates \ cmake \ debug \ obj \ armeabi-v7a \ libnative-lib.so CMa keFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o ../../../../openssl-armeabi-v7a/lib/libcrypto.a ../../ ../../openssl-armeabi-v7a/lib/libssl.a -llog -lm" C:/ android / sdk / ndk-bundle / sources / cxx-stl / gnu-libstdc ++ / 4.9 / libs / armeabi-V7A / libgnustl_static.a" &安培;&安培; cd。"   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner:error:undefined reference to' signal'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner:error:undefined reference to' tcsetattr'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner:error:undefined reference to' tcsetattr'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console:error:undefined reference to' tcgetattr'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_expand_block:error:undefined reference to' inflate'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_compress_block:error:undefined reference to' deflate'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_free:错误:未定义引用' inflateEnd'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_free:错误:未定义引用' deflateEnd'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_finish:error:undefined reference to' inflateEnd'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_finish:error:undefined reference to' deflateEnd'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_init:error:undefined reference to' inflateInit _'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_init:error:undefined reference to' deflateInit _'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_ctrl:error:undefined reference to' deflate'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_ctrl:error:undefined reference to' zError'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write:error:undefined reference to' deflate'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write:error:undefined reference to' zError'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write:error:undefined reference to' deflateInit _'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read:错误:未定义引用'膨胀'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read:error:undefined reference to' zError'   ../../../../openssl-armeabi-v7a/lib/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read:错误:未定义引用' inflateInit _'   clang ++。exe:错误:链接器命令失败,退出代码为1(使用-v查看调用)   忍者:构建停止:子命令失败。

在下面分享应用的build.gradle

defaultConfig {
    applicationId "com.example.openssl"
    minSdkVersion 14
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    externalNativeBuild {
        cmake {
            cppFlags ""
        }
    }
    ndk {
        abiFilters 'armeabi-v7a'
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}

文件夹结构:

enter image description here

0 个答案:

没有答案