Skip to content

Instantly share code, notes, and snippets.

@jeffrafter
Last active August 13, 2019 09:52
Show Gist options
  • Save jeffrafter/93e4efc2119e5ecd84b4367c9f9c655a to your computer and use it in GitHub Desktop.
Save jeffrafter/93e4efc2119e5ecd84b4367c9f9c655a to your computer and use it in GitHub Desktop.
Install Android NDK r14b via homebew

When working with Unreal and trying to build for Android (like the Oculus Quest) it recommends having version r14b of the Android NDK tools installed. You could install this manually by downloading it or you can install it via homebrew.

Unfortunately the version available via homebrew is r19. The legacy formula has some problems. This formula uses the legacy formula and adds the more recent installation fixes.

brew cask install https://gist.githubusercontent.com/jeffrafter/93e4efc2119e5ecd84b4367c9f9c655a/raw/058499c99a697649d5116fce1c9dfa204bb25e54/android-ndk.rb
cask 'android-ndk' do
version '14b'
sha256 'f5373dcb8ddc1ba8a4ccee864cba2cbdf500b2a32d6497378dfd32b375a8e6fa'
# dl.google.com/android/repository/android-ndk was verified as official when first introduced to the cask
url "https://dl.google.com/android/repository/android-ndk-r#{version}-darwin-x86_64.zip"
name 'Android NDK'
homepage 'https://developer.android.com/ndk/'
conflicts_with cask: 'crystax-ndk'
# shim script (https://github.com/caskroom/homebrew-cask/issues/18809)
shimscript = "#{staged_path}/ndk_exec.sh"
preflight do
FileUtils.ln_sf("#{staged_path}/android-ndk-r#{version}", "#{HOMEBREW_PREFIX}/share/android-ndk")
IO.write shimscript, <<~EOS
#!/bin/bash
readonly executable="#{staged_path}/android-ndk-r#{version}/$(basename ${0})"
test -f "${executable}" && exec "${executable}" "${@}"
EOS
end
%w[
ndk-build
ndk-depends
ndk-gdb
ndk-stack
ndk-which
].each { |link_name| binary shimscript, target: link_name }
uninstall_postflight do
FileUtils.rm("#{HOMEBREW_PREFIX}/share/android-ndk")
end
caveats <<-EOS
You may want to add to your profile:
'export ANDROID_NDK_HOME="#{HOMEBREW_PREFIX}/opt/android-ndk"'
EOS
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment