Android NDK:生成命令失败。使用参数执行过程时出错

时间:2020-10-31 15:42:28

标签: android c++ cmake android-ndk

我正在尝试为Hello World Android NDK应用构建APK。 但是我正在错误以下。 我尝试在网络中寻找解决方案,但找不到解决方案。

Build command failed.
Error while executing process E:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C E:\Android\ndk\CppAndroidIosExample-master\MyNDKApp\app\.cxx\cmake\debug\armeabi-v7a native-lib}
ninja: Entering directory `E:\Android\ndk\CppAndroidIosExample-master\MyNDKApp\app\.cxx\cmake\debug\armeabi-v7a'
[1/2] Building CXX object CMakeFiles/native-lib.dir/native-lib.cpp.o
FAILED: CMakeFiles/native-lib.dir/native-lib.cpp.o 
E:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\ndk\21.1.6352462\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi23 --gcc-toolchain=E:/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=E:/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/windows-x86_64/sysroot  -Dnative_lib_EXPORTS  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/native-lib.dir/native-lib.cpp.o -MF CMakeFiles\native-lib.dir\native-lib.cpp.o.d -o CMakeFiles/native-lib.dir/native-lib.cpp.o -c E:/Android/ndk/CppAndroidIosExample-master/MyNDKApp/app/src/main/cpp/native-lib.cpp
ninja: build stopped: subcommand failed.

代码:

#include <jni.h>
#include <string>

extern "C" JNIEXPORT jstring JNICALL
Java_com_anz_myndkapp_MainActivity_stringFromJNI(
        JNIEnv* env,
        jobject /* this */) {
    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}

0 个答案:

没有答案