Facebook Buck: BUILD FAILED: No native platforms detected. Probably Android NDK is not configured properly

456 views Asked by At

I am trying to build Android app using the facebook's buck build system but I am getting Build Failed error.

I am getting this same error on both MAC as well as WINDOWS

buckconfig file

[cache]
  mode = dir

[cxx]
  default_platform = iphonesimulator-x86_64
  cflags = -g -std=c11
  cxxflags = -g -std=c++14
  # Many ARC APIs don't compile with separate preprocess and compile.
  combined_preprocess_and_compile = true

[alias]
  demo_app_android = //android:demo-app
  demo_app_ios = //ios:BuckDemoApp

[apple]
  xctool_zip_target = //third-party/ios/xctool:xctool-minimal-zip

[ndk]
  ndk_version = 16.1.4479499
  app_platform = android-26

[android]
  build_tools_version = 26.0.2
  target = Google Inc.:Google APIs:26

[java]
  src_roots = /android/java/
  source_level = 7
  target_level = 7

[project]
    default_android_manifest = //android/AndroidManifest.xml
    ignore = .buckd, \
             .hg, \
             .git, \
             .idea, \
             buck-cache, \
             buck-out, \

Environment Variables:

$ env | grep ANDROID_
ANDROID_HOME=<path>/Android/sdk
ANDROID_NDK_REPOSITORY=<path>/Android/sdk/ndk-bundle
ANDROID_SDK=<path>/Library/Android/sdk

Error Stack Trace:

Building: finished in 0.0 sec
  Total time: 0.0 sec
BUILD FAILED: No native platforms detected. Probably Android NDK is not configured properly.

I am not getting that what I am missing. Appreciate your help.

Thanks

2

There are 2 answers

0
Patrick Cho On BEST ANSWER

I had the same error when trying to build the sample Android APP. I tried several things to clearly understand the behaviour of the .buckconfig settings and environment variables.

Set ndk_path

you can set ndk path directly. I've set this variable instead of setting ndk_version(such as 'r10e') Keep in mind that

The environment variables ANDROID_NDK and NDK_HOME both supercede the buckconfig setting.

Create a repo folder (recommended)

Download ndk bundle and unzip it into a folder that serves as a repository folder and set it to ANDROID_NDK_REPOSITORY env var. So the path can be used to get the correct ndk version. In this case only thing you have to do is setting the version of NDK bundle and buck will automatically get the right version for you.

Currently there is error with Buck with the Java9.

Just to add more. If you are using java9 then downgrade to java8 as buck uses the sun/misc/BASE64Encoder which is removed in java9.

To keep versions of java8 and java9 in mac. I have implemented below command lines in .bash_profile.

export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_9_HOME=$(/usr/libexec/java_home -v9)

alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java9='export JAVA_HOME=$JAVA_9_HOME'

#default java8
export JAVA_HOME=$JAVA_8_HOME
0
tcb On

Try older version of NDK (15 or older) and make sure /Android/sdk/ndk-bundle contains a directory with that version so it looks like /Android/sdk/ndk-bundle/android-ndk-r15.