android-yolo icon indicating copy to clipboard operation
android-yolo copied to clipboard

ndk-build error

Open lisongting opened this issue 7 years ago • 11 comments

Hi @natanielruiz ,I try to use ndk-build ,but there are some errors,could you please tell me how to fix it ?

E:\Xbot_material\AI-Camera-YOLO\jni-build>ndk-build
Android NDK: WARNING:jni/Android.mk:tensorflow_demo: non-system libraries in linker flags: jni/libs/armeabi-v7a/libprotos_all_cc.a jni/libs/armeabi-v7a/libprotobuf.a jni/libs/armeabi-v7a/libprotobuf_lite.a C:/Users/lisongting/AppData/Local/Android/Sdk/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a C:/Users/lisongting/AppData/Local/Android/Sdk/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK:     current module
[armeabi-v7a] Compile++ arm  : tensorflow_demo <= tensorflow_jni.cc
jni/./tensorflow_jni.cc: In function 'std::string ClassifyImage(const {anonymous}::RGBA*)':
jni/./tensorflow_jni.cc:318:33: error: 'output' cannot be used as a function
     const float value = output(i);
                                 ^
jni/./tensorflow_jni.cc:319:16: error: base operand of '->' has non-pointer type 'std::vector<float>'
     top_results->push_back(value);
                ^
jni/./tensorflow_jni.cc:321:27: error: base operand of '->' has non-pointer type 'std::vector<float>'
   std::reverse(top_results->begin(), top_results->end());
                           ^
jni/./tensorflow_jni.cc:321:49: error: base operand of '->' has non-pointer type 'std::vector<float>'
   std::reverse(top_results->begin(), top_results->end());
                                                 ^
jni/./tensorflow_jni.cc: At global scope:
jni/./tensorflow_jni.cc:171:13: warning: 'void GetTopN(const Eigen::TensorMap<Eigen::Tensor<float, 1, 1, int>, 16>&, int, float, std::vector<std::pair<float, int> >*)' defined but not used [-Wunused-function]
 static void GetTopN(
             ^
make: *** [obj/local/armeabi-v7a/objs/tensorflow_demo/./tensorflow_jni.o] Error 1

lisongting avatar Aug 27 '17 02:08 lisongting

Have you solved this errors? If so, could you tell me how to solve? I have got stuck in this problem for a week but cannot find any idea to solve. Thank you very much!

haophancs avatar Dec 20 '17 04:12 haophancs

@ph77894456 Change the source code and rebuild. Are you Chinese? May be this report will help you: https://github.com/lisongting/weloveinterns/blob/master/reports/YOLO-in-Android.md

lisongting avatar Dec 20 '17 05:12 lisongting

Do you have the same reports in English?

haophancs avatar Dec 20 '17 06:12 haophancs

I am sorry.I don't have the report in English .

lisongting avatar Dec 20 '17 06:12 lisongting

OK, anyway thank you for nice articles!

haophancs avatar Dec 20 '17 07:12 haophancs

Thanks for your report, I could built ndk successfully. But when trying to use this jniLibs in other package, the app crashed although I've changed the method with my package name in METHOD_NAME (in imageutils_jni.cc and tensorflow_jni.cc) and recompile ndk as you explained in the report: "#define TENSORFLOW_METHOD(METHOD_NAME)
Java_com_paperfish_aicameratest2_TensorFlowClassifier_" And the jni functions still "cannot correspoding". Could you help me how to solve? Thank you very much!

haophancs avatar Dec 21 '17 16:12 haophancs

Paste your crashed log in Logcat and let me see. If you can‘t see any log information after crashing happened.ClickTools ->Android ->Android Device Monitor . Then you can see the error information in Logcat.

I think there are something wrong with declaration of your JNI functions,probably. This link may be helpful: https://developer.android.com/training/articles/perf-jni.html

lisongting avatar Dec 22 '17 01:12 lisongting

I run the app in Xiaomi Redmi Note 4X, MIUI v8.5.8


Build fingerprint: 'xiaomi/mido/mido:7.0/NRD90M/V8.5.8.0.NCFMIED:user/release-keys' Revision: '0' ABI: 'arm' pid: 1448, tid: 1588, name: ImageListener >>> com.haophan.vias.vehiclesdetector <<< signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- Abort message: 'jni_utils.cc:123 Check failed: message->ParseFromArray(memory, data_size) ' r0 00000000 r1 00000634 r2 00000006 r3 00000008 r4 ccb6f978 r5 00000006 r6 ccb6f920 r7 0000010c r8 ccb6e534 r9 ccb6e3c0 sl cbfb51d8 fp 00000000 ip 00000000 sp ccb6e368 lr e9aea2c7 pc e9aecb48 cpsr 200f0010

backtrace: #00 pc 00049b48 /system/lib/libc.so (tgkill+12) #01 pc 000472c3 /system/lib/libc.so (pthread_kill+34) #02 pc 0001d565 /system/lib/libc.so (raise+10) #03 pc 000190b1 /system/lib/libc.so (__libc_android_abort+34) #04 pc 00017114 /system/lib/libc.so (abort+4) #05 pc 0053d03c /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so #06 pc 0053d1bc /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so #07 pc 0053d1d8 /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so #08 pc 00075500 /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so (_Z15ReadFileToProtoP13AAssetManagerPKcPN6google8protobuf11MessageLiteE+996) #09 pc 00077bdc /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so (Java_org_tensorflow_demo_TensorFlowClassifier_initializeTensorFlow+1084) #10 pc 0045187d /data/app/com.haophan.vias.vehiclesdetector-1/oat/arm/base.odex (offset 0x413000)

haophancs avatar Dec 22 '17 04:12 haophancs

add

aaptOptions {
        noCompress 'pb'
    }

to build.gradle.

lisongting avatar Dec 23 '17 01:12 lisongting

I've added thì code to build.gradle (module: app) but nothing changed

haophancs avatar Dec 23 '17 02:12 haophancs

Have you downloaded the .pb file and added into your project?

lisongting avatar Dec 23 '17 02:12 lisongting