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

Issue while building the android example using bazel #1281

Closed
Aprameyah opened this issue Nov 10, 2020 · 15 comments
Closed

Issue while building the android example using bazel #1281

Aprameyah opened this issue Nov 10, 2020 · 15 comments
Assignees

Comments

@Aprameyah
Copy link

I'm using the link to build android example of the hand tracking app. I have installed Android studio and have specified the path for sdk and ndk. Im getting the following error:

ERROR: /home/sreehari/TP_WS/mediapipe/WORKSPACE:242:23: //external:android/crosstool depends on @androidndk//:default_crosstool in repository @androidndk which failed to fetch. no such package '@androidndk//': Expected directory at /home/sreehari/Android/Sdk/ndk/22.0.6917172/platforms but it is not a directory or it does not exist. Unable to read the Android NDK at /home/sreehari/Android/Sdk/ndk/22.0.6917172, the path may be invalid. Is the path in android_ndk_repository() or ANDROID_NDK_HOME set correctly? If the path is correct, the contents in the Android NDK directory may have been modified.
ERROR: Analysis of target '//mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu' failed; build aborted: Analysis failed

Please provide a solution for the same.

@jiuqiant
Copy link
Contributor

The error is "Expected directory at /home/sreehari/Android/Sdk/ndk/22.0.6917172/platforms but it is not a directory or it does not exist. Unable to read the Android NDK at /home/sreehari/Android/Sdk/ndk/22.0.6917172, the path may be invalid.".

Can you do ls /home/sreehari/Android/Sdk/ndk/22.0.6917172 to inspect this directory?

@jiuqiant jiuqiant self-assigned this Nov 10, 2020
@Aprameyah
Copy link
Author

@jiuqiant it is a directory, and the path is valid.

@jiuqiant
Copy link
Contributor

What's in the /home/sreehari/Android/Sdk/ndk/22.0.6917172 directory? Does it have a platforms subdirctory? I am asking because the error says /home/sreehari/Android/Sdk/ndk/22.0.6917172/platforms is not a directory or does not exist.

Normally, the directory should look like this:

$ ls $ANDROID_NDK_HOME 
CHANGELOG.md		ndk-gdb			shader-tools
NOTICE			ndk-stack		simpleperf
NOTICE.toolchain	ndk-which		source.properties
README.md		package.xml		sources
build			platforms		sysroot
meta			prebuilt		toolchains
ndk-build		python-packages		wrap.sh

@Aprameyah
Copy link
Author

Yes it is similar

@jiuqiant
Copy link
Contributor

Try bazel clean --expunge to get rid of the cache and then rerun the build command.
If that still doesn't work, I believe that's an issue of Bazel. Please file an issue against https://github.com/bazelbuild/bazel.

@Aprameyah
Copy link
Author

@jiuqiant I had already tried clearing the cache, can reverting back to previous version of bazel fix this issue?

@jiuqiant
Copy link
Contributor

If you plan to downgrade to an earlier version of Bazel, please checkout an earlier version of MediaPipe as well. Another thing you can try is to delete the ndk directory and reinstall it by Android Studio again. The error message also mentions that "If the path is correct, the contents in the Android NDK directory may have been modified."

@Aprameyah
Copy link
Author

@jiuqiant changed the ANDROID_NDK_HOME path to Android/Sdk/ndk-bundle/android-ndk-r18b/ and its building now, I haven't changed the bazel version.

@pulpoec
Copy link

pulpoec commented Nov 13, 2020

Hello,
Same problem here. But I don't have the ~/Android/Sdk/ndk/platforms folder

this is the list of my folder

xavier@xavier-VM:~/Android/Sdk/ndk/22.0.6917172$ ls
build         ndk-gdb    NOTICE            python-packages  source.properties
CHANGELOG.md  ndk-lldb   NOTICE.toolchain  README.md        sources
meta          ndk-stack  package.xml       shader-tools     toolchains
ndk-build     ndk-which  prebuilt          simpleperf       wrap.sh

and the Android/Sdk/ndk-bundle/android-ndk-r18b/ doesn't exist neither

This is a fresh install of Android Studio
I do the bazel clean --expunge too

@Aprameyah
Copy link
Author

@pulpoec I downloaded the ndk separately in Android studio and made it work.

@duy-maimanh
Copy link

Hi @Aprameyah Ap
I download NDK 22 at here https://developer.android.com/ndk/downloads.
But i didn't see "platforms" folder.
How you fix it ?

@DrStoop
Copy link

DrStoop commented Jan 19, 2021

Install older NDK-version e.g. 18.1.5063045

Abstract: NDK folder & file structure has changed somewhere between 18.xxx & 20.xxx and bazel (e.g. 3.7.0) does not get it. So simply installing an older NDK-version fixed this issue and issue #98 for me.

I had the same problem, either .../platforms was not found or when creating the platforms-folder then RELEASE.TXT file could not be found. I comes out that the newest NDK (20.0.7026061) version has changed it's folder & file structures which bazel (version 3.7.0) has not adopted for, yet. Only the older NDKs, e.g. 18.1.5063045, build without errors:

developer@9da2071fdabf:~/Android/Sdk/ndk$ ll
total 0
drwxr-xr-x 1 developer developer  48 Jan 19 19:12 ./
drwxr-xr-x 1 developer developer 262 Jan 19 16:00 ../
drwxr-xr-x 1 developer developer 420 Jan 19 19:12 18.1.5063045/
drwxr-xr-x 1 developer developer 382 Jan 19 17:27 22.0.7026061/
developer@9da2071fdabf:~/Android/Sdk/ndk$ ll 18.1.5063045/
total 3660
drwxr-xr-x 1 developer developer     420 Jan 19 19:12 ./
drwxr-xr-x 1 developer developer      48 Jan 19 19:12 ../
-rw-r--r-- 1 developer developer    5772 Jan 19 19:12 CHANGELOG.md
-rw-r--r-- 1 developer developer 3476824 Jan 19 19:12 NOTICE
-rw-r--r-- 1 developer developer  210037 Jan 19 19:12 NOTICE.toolchain
-rw-r--r-- 1 developer developer     730 Jan 19 19:12 README.md
drwxr-xr-x 1 developer developer     534 Jan 19 19:12 build/
drwxr-xr-x 1 developer developer      46 Jan 19 19:12 meta/
-rwxr-xr-x 1 developer developer      72 Jan 19 19:12 ndk-build*
-rwxr-xr-x 1 developer developer      94 Jan 19 19:12 ndk-depends*
-rwxr-xr-x 1 developer developer      90 Jan 19 19:12 ndk-gdb*
-rwxr-xr-x 1 developer developer      92 Jan 19 19:12 ndk-stack*
-rwxr-xr-x 1 developer developer      92 Jan 19 19:12 ndk-which*
-rw-r--r-- 1 developer developer   17856 Jan 19 19:12 package.xml

drwxr-xr-x 1 developer developer     220 Jan 19 19:12 platforms/

drwxr-xr-x 1 developer developer     122 Jan 19 19:12 prebuilt/
drwxr-xr-x 1 developer developer      84 Jan 19 19:12 python-packages/
drwxr-xr-x 1 developer developer      24 Jan 19 19:12 shader-tools/
drwxr-xr-x 1 developer developer     612 Jan 19 19:12 simpleperf/
-rw-r--r-- 1 developer developer      51 Jan 19 19:12 source.properties
drwxr-xr-x 1 developer developer      50 Jan 19 19:12 sources/
drwxr-xr-x 1 developer developer      18 Jan 19 19:12 sysroot/
drwxr-xr-x 1 developer developer     166 Jan 19 19:12 toolchains/
drwxr-xr-x 1 developer developer     122 Jan 19 19:12 wrap.sh/

developer@9da2071fdabf:~/Android/Sdk/ndk$ ll 22.0.7026061/
total 1576
drwxr-xr-x 1 developer developer    382 Jan 19 17:27 ./
drwxr-xr-x 1 developer developer     48 Jan 19 19:12 ../
-rw-r--r-- 1 developer developer   8186 Jan 19 17:27 CHANGELOG.md
-rw-r--r-- 1 developer developer 666233 Jan 19 17:27 NOTICE
-rw-r--r-- 1 developer developer 888795 Jan 19 17:27 NOTICE.toolchain
-rw-r--r-- 1 developer developer    730 Jan 19 17:27 README.md
drwxr-xr-x 1 developer developer    556 Jan 19 17:27 build/
drwxr-xr-x 1 developer developer     78 Jan 19 17:27 meta/
-rwxr-xr-x 1 developer developer     72 Jan 19 17:27 ndk-build*
-rwxr-xr-x 1 developer developer     90 Jan 19 17:27 ndk-gdb*
-rwxr-xr-x 1 developer developer     90 Jan 19 17:27 ndk-lldb*
-rwxr-xr-x 1 developer developer     92 Jan 19 17:27 ndk-stack*
-rwxr-xr-x 1 developer developer     92 Jan 19 17:27 ndk-which*
-rw-r--r-- 1 developer developer  17856 Jan 19 17:27 package.xml
drwxr-xr-x 1 developer developer    122 Jan 19 17:27 prebuilt/
drwxr-xr-x 1 developer developer     64 Jan 19 17:27 python-packages/
drwxr-xr-x 1 developer developer     24 Jan 19 17:27 shader-tools/
drwxr-xr-x 1 developer developer    656 Jan 19 17:27 simpleperf/
-rw-r--r-- 1 developer developer     51 Jan 19 17:27 source.properties
drwxr-xr-x 1 developer developer     50 Jan 19 17:27 sources/
drwxr-xr-x 1 developer developer    166 Jan 19 17:27 toolchains/
drwxr-xr-x 1 developer developer     14 Jan 19 17:27 wrap.sh/

@fesago90
Copy link

From bazel source code: https://github.com/bazelbuild/bazel/blob/13aba68083fa0f7cfc21c1d994c4ae50014ab61c/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java#L322

Edit the WORKSPACE file and change the android_ndk_repository rule to include api_level=22 or whatever ndk you downloaded; this worked for me.

@jwhpryor
Copy link

Hello, I'm also affected by this issue. I'm missing the platforms directory and no RELEASE.txt.

It's great we have a workaround, but it would be really awesome if we could get NDK code building for Bazel with the default configurations. It's be nice if the NDK sample for Android building with Bazel worked out of the box, is there a bug I could possibly follow for this?

@jiuqiant
Copy link
Contributor

Bazel doesn't support android ndk r22+ yet. Please use r21 instead.
See more details in bazelbuild/bazel#12889.

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

7 participants