Unable to generate apk file for android command is failing during bazel build

All the steps reffered in https://github.com/mozilla/DeepSpeech/blob/v0.6.1/native_client/README.rst is successfully done before android device tag.
i want to use deepspeech in android device. so I am further following steps to do so. but during bazel build for arm64, it is failing with following error.

$ bazel build --workspace_status_command=“bash native_client/bazel_workspace_status_cmd.sh” --config=monolithic --config=android --config=android_arm64 --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++11 --copt=-D_GLIBCXX_USE_C99 //native_client:libdeepspeech.so

output error:-
WARNING: The following configs were expanded more than once: [android]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
WARNING: option ‘–crosstool_top’ was expanded to from both option ‘–config=download_clang’ (source /home/udaram/Desktop/TCS_Internship/DeepspeechModel/tensorflow/.tf_configure.bazelrc) and option ‘–config=android’ (source command line options)
INFO: Analysed target //native_client:libdeepspeech.so (0 packages loaded, 0 targets configured).
INFO: Found 1 target…
ERROR: /home/udaram/Desktop/TCS_Internship/DeepspeechModel/tensorflow/native_client/BUILD:63:1: C++ compilation of rule ‘//native_client:decoder’ failed (Exit 127)
external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
Target //native_client:libdeepspeech.so failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 9.142s, Critical Path: 0.74s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

If I am doing wrong, please guide me toward right way to generate apk file for Android device.
Thanks in advance
@lissyx please guide

I have no idea what that is, sorry. You’ll have to debug it on our own.

Besides, why do you need to rebuild the APK ? We already have libdeepspeech AAR packaged and published on JCenter …

1 Like

Anyway, given the command line it’s more of a clang / Android NDK issue than a deepspeech one. On debian there’s a libtinfo5 package, maybe try?

1 Like

all the above issues ha been resolved succesfully…
but facing problem in following steps given at this link…

on running DeepSpeech/native_client/java$ ./gradlew libdeepspeech:build
getting output like this…

Configure project :libdeepspeech
arm64-v8a armeabi-v7a x86_64WARNING: Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.
Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.

Task :libdeepspeech:externalNativeBuildDebug FAILED
Build deepspeech-jni_armeabi-v7a
ninja: Entering directory `/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/libdeepspeech/.cxx/cmake/debug/armeabi-v7a’
[1/1] Linking CXX shared library …/…/…/…/build/intermediates/cmake/debug/obj/armeabi-v7a/libdeepspeech-jni.so
FAILED: …/…/…/…/build/intermediates/cmake/debug/obj/armeabi-v7a/libdeepspeech-jni.so
: && /home/udaram/Android/Sdk/ndk-build/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi --gcc-toolchain=/home/udaram/Android/Sdk/ndk-build/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/udaram/Android/Sdk/ndk-build/sysroot -fPIC -isystem /home/udaram/Android/Sdk/ndk-build/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,–noexecstack -Wformat -Werror=format-security -std=c++11 -O0 -fno-limit-debug-info -Wl,–exclude-libs,libgcc.a -Wl,–exclude-libs,libatomic.a -nostdlib++ --sysroot /home/udaram/Android/Sdk/ndk-build/platforms/android-21/arch-arm -Wl,–build-id -Wl,–warn-shared-textrel -Wl,–fatal-warnings -Wl,–fix-cortex-a8 -Wl,–exclude-libs,libunwind.a -L/home/udaram/Android/Sdk/ndk-build/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,–no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libdeepspeech-jni.so -o …/…/…/…/build/intermediates/cmake/debug/obj/armeabi-v7a/libdeepspeech-jni.so CMakeFiles/deepspeech-jni.dir/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp.o …/…/…/…/libs/armeabi-v7a/libdeepspeech.so /home/udaram/Android/Sdk/ndk-build/platforms/android-21/arch-arm/usr/lib/liblog.so -latomic -lm “/home/udaram/Android/Sdk/ndk-build/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a” “/home/udaram/Android/Sdk/ndk-build/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++abi.a” “/home/udaram/Android/Sdk/ndk-build/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a” “-ldl” && cd /home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/libdeepspeech/.cxx/cmake/debug/armeabi-v7a && /home/udaram/Android/Sdk/cmake/3.10.2.4988404/bin/cmake -E copy /home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/libdeepspeech/libs/armeabi-v7a/libdeepspeech.so /home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/libdeepspeech/build/intermediates/cmake/debug/obj/armeabi-v7a/libdeepspeech.so
/home/udaram/Android/Sdk/ndk-build/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/…/…/…/…/arm-linux-androideabi/bin/ld: error: …/…/…/…/libs/armeabi-v7a/libdeepspeech.so: incompatible target
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:908: error: undefined reference to ‘DS_FreeMetadata’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1217: error: undefined reference to ‘DS_CreateModel’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1232: error: undefined reference to ‘DS_GetModelBeamWidth’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1248: error: undefined reference to ‘DS_SetModelBeamWidth’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1262: error: undefined reference to ‘DS_GetModelSampleRate’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1274: error: undefined reference to ‘DS_FreeModel’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1292: error: undefined reference to ‘DS_EnableExternalScorer’
/home/udaram/Desktop/TCS_Internship/DeepspeechModel/DeepSpeech/native_client/java/jni/deepspeech_wrap.cpp:1307: error: undefined reference to ‘DS_DisableExternalScorer’

i am not able to follow the exact steps on above given link @lissyx could you eloborate those steps in simple way…
i will be thank full to you.
my goal is to generate deepspeech apk file for android

You are linking against wrong version …

no, I can’t make it more simple unless you point what is unclear to you

why do you need to rebuild it, we already have libdeepspeech AAR dependency available on JCenter …

https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/native_client.arm64.cpu.android.tar.xz

https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/native_client.armv7.cpu.android.tar.xz

Please rather use JCenter published AAR …

But where is it? Can you link it?

https://bintray.com/alissy/org.mozilla.deepspeech/libdeepspeech/0.8.2

1 Like