miyosuda / TensorFlowAndroidMNIST

Tensorflow MNIST demo on Android
265 stars 108 forks source link

How to build the library for API Level 19 ?? #5

Open alan23273850 opened 8 years ago

alan23273850 commented 8 years ago

Hi! I am a freshman developer to JNI and may I ask you a question about this?? I want to build this project on my android phone with API Level 19. I just modified APP_PLATFORM := android-21 to APP_PLATFORM := android-19 in Application.mk. However, it could not find the definition of errno. And after adding android-21 include path, the error becomes

..../armeabi-v7a/libandroid_tensorflow_lib_lite.lo(arena.o):arena.cc:function _GLOBAL__sub_I_arena.cc: error: undefined reference to 'getpagesize' ..../libandroid_tensorflow_lib_lite.lo(numbers.o):numbers.cc:function tensorflow::strings::safestrtof(char const, float_): error: undefined reference to 'strtof'

Therefore I think binary libraries in TensorFlowAndroidMNIST/jni-build/jni/libs/armeabi-v7a/ can only be used in android-21 level. So my question is where did you find these binary libraries?? By directly copying from the official tensorflow project or rebuilding from the source?? How could I rebuild the source codes to generate the same libraries supporting android-19??

Sorry for my poor English and thank you in advance!!

miyosuda commented 8 years ago

Sorry for late in reply.

I used to extract .a and .lo library files from tensorflow's original android demo by building with bazel. First, I built Tensorflow r0.8's Android demo with following this instruction using bezel.

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android/

After that I extracted .a and .lo files from "bazel-out" dir.

I haven't tried yet, but if you would like to change supporting android version, you can change it in WORKSPACE file.

https://github.com/tensorflow/tensorflow/blob/r0.8/WORKSPACE#L13

AnjaConev commented 7 years ago

I have the same issue. Did you menage to solve it?

alan23273850 commented 7 years ago

Nope, after that I have tried lots of cross combinations of Android SDK version and JNI version, and all of them failed. I forget some details because this issue has been for a long time. The only thing I can guarantee is that the procedure is very complicated.

This may be a non-solvable issue because tensorflow was invented after API Level 19 and it is certain that the developers did not consider the backward compatibility. In addition, most smartphones' API levels are beyond 19, so maybe ignoring these old versions is a necessary evil.

Of course, anyone who indeed solves this problem is very very welcome!!!

AnjaConev commented 7 years ago

Do you have experience with any other machine learning libraries that do work on API 19 that you would suggest?

alan23273850 commented 7 years ago

After googling for a while, I have found a good material: https://en.wikipedia.org/wiki/Weka_(machine_learning). It is also an ML software in Java, and has Android version recently. Although I have not tried it before, I guess it can run on Android 4.4 because of its history. Hope it helps!