Search code examples
androidandroid-ndktensorflowbazel

TensorFlow Android demo: unable to build with Bazel, could not read RELEASE.TXT


Recently I've been learning how to use TensorFlow, and wanted to set up the Android demos on my computer to see how they worked. I followed the instructions provided here, with the only differences being that I installed the Android SDK through Android Studio, and installed the Android NDK through the SDK Manager. Up until $ bazel build //tensorflow/examples/android:tensorflow_demo, everything worked fine, but after that, I got this error from the terminal:

ERROR: no such package '@androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).
ERROR: no such package '@androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).

From looking around at similar issues, my understanding is that this error is because the RELEASE.TXT file isn't included in the most recent version of Android NDK. This issue suggested downgrading to a previous version of NDK which contains a RELEASE.TXT file, and provided links to download such versions. However, the link that I followed (https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin) downloaded a .bin file, which is unusable to me. That post also suggested commenting out the NDK entry in the WORKSPACE file, but I haven't tried that yet, since I don't know if it will cause further complications down the road.

Another approach that I've tried is going to the path indicated by the error log (/home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk) and creating a blank RELEASE.TXT file, which made no difference. (I wasn't able to create one in the NDK that I installed, since it was in the form of a .jar file at the path /home/me/android-studio/android-studio/plugins/android-ndk/lib, thus the only way I could see was this path.)

As it stands, I'm at a dead end. Is there another way to resolve this issue without downgrading or commenting out the NDK entry? If not, how can I install a previous version of Android NDK?


Solution

  • I also posted this as issue #3175 in the official GitHub repository for TensorFlow, and it's been resolved. A play-by-play of the steps I followed to solve the problem can be found in that thread. It's a bit convoluted, so the steps I believe will solve an issue like this are as follows:

    1. If you didn't use the --recursive option when git cloning the TensorFlow repository, re-clone it using that.
    2. Downgrade to Android NDK r11c (and make sure to update the WORKSPACE file accordingly). A link for the Linux version can be found in the GitHub thread.
    3. Check the version of your Android SDK and build tools. If they differ from the default versions written in the WORKSPACE file, make sure to change that.
    4. You may run into a TensorFlow issue that is, as of yet, unresolved. (#3374) If so, run ./configure as a workaround.

    And that should allow the Bazel build to proceed successfully.