Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndk-build error #12

Open
lisongting opened this issue Aug 27, 2017 · 11 comments
Open

ndk-build error #12

lisongting opened this issue Aug 27, 2017 · 11 comments

Comments

@lisongting
Copy link

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
@haophancs haophancs mentioned this issue Sep 18, 2017
@haophancs
Copy link

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!

@lisongting
Copy link
Author

@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

@haophancs
Copy link

Do you have the same reports in English?

@lisongting
Copy link
Author

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

@haophancs
Copy link

OK, anyway thank you for nice articles!

@haophancs
Copy link

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!

@lisongting
Copy link
Author

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

@haophancs
Copy link

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)
#1 pc 000472c3 /system/lib/libc.so (pthread_kill+34)
#2 pc 0001d565 /system/lib/libc.so (raise+10)
#3 pc 000190b1 /system/lib/libc.so (__libc_android_abort+34)
#4 pc 00017114 /system/lib/libc.so (abort+4)
#5 pc 0053d03c /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so
#6 pc 0053d1bc /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so
#7 pc 0053d1d8 /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so
#8 pc 00075500 /data/app/com.haophan.vias.vehiclesdetector-1/lib/arm/libtensorflow_demo.so (_Z15ReadFileToProtoP13AAssetManagerPKcPN6google8protobuf11MessageLiteE+996)
#9 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)

@lisongting
Copy link
Author

add

aaptOptions {
        noCompress 'pb'
    }

to build.gradle.

@haophancs
Copy link

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

@lisongting
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants