[Unity] Manual set Android NDK path when UnityHub Add Modules failed

1. Hack the NDK version number
2. Fix NDK Signing

Sometimes UnityHub can’t download Android SDK & NDK, then you maybe face the following messages:

The server is currently unresponsive.
Installation Failed, something went wrong installing modules for Unity.

UnityHub AddModules FailedUnityHub AddModules FailedUnityHub AddModules Failed

Unity will indicate the specific NDK version you need.
Ex. Unity 2019.4.13f1 => NDK 19.0.5232133

But you might only found the latest of the main version of NDK.
Ex. NDK 19.2.5345600
https://developer.android.com/ndk/downloads/older_releases

1. Hack the NDK version number

Open file source.properties with a txt file
Modify Pkg.Revision to your NDK target version number
Pkg.Revision = 19.0.5232133

2. Fix NDK Signing

Open terminal, go to NDK root and execute the following scripts.

echo "Resetting Extended Attributes"
sudo xattr -cr toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
sudo xattr -cr toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
sudo xattr -cr toolchains/llvm/prebuilt/darwin-x86_64/lib64/libc++.dylib
sudo xattr -cr toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/ld.bfd
sudo xattr -cr toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/ld.gold
sudo xattr -cr toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objcopy
sudo xattr -cr toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip
sudo xattr -cr toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ld.bfd
sudo xattr -cr toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ld.gold
sudo xattr -cr toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-objcopy
sudo xattr -cr toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-strip
sudo xattr -cr toolchains/x86-4.9/prebuilt/darwin-x86_64/i686-linux-android/bin/ld.bfd
sudo xattr -cr toolchains/x86-4.9/prebuilt/darwin-x86_64/i686-linux-android/bin/ld.gold
sudo xattr -cr toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-objcopy
sudo xattr -cr toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-strip
sudo xattr -cr toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-objcopy
sudo xattr -cr toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-strip
echo "Fixing NDK Signing"
sudo codesign --force --deep --sign - toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
sudo codesign --force --deep --sign - toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
sudo codesign --force --deep --sign - toolchains/llvm/prebuilt/darwin-x86_64/lib64/libc++.dylib
sudo codesign --force --deep --sign - toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/ld.bfd
sudo codesign --force --deep --sign - toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/ld.gold
sudo codesign --force --deep --sign - toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objcopy
sudo codesign --force --deep --sign - toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip
sudo codesign --force --deep --sign - toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ld.bfd
sudo codesign --force --deep --sign - toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ld.gold
sudo codesign --force --deep --sign - toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-objcopy
sudo codesign --force --deep --sign - toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-strip
sudo codesign --force --deep --sign - toolchains/x86-4.9/prebuilt/darwin-x86_64/i686-linux-android/bin/ld.bfd
sudo codesign --force --deep --sign - toolchains/x86-4.9/prebuilt/darwin-x86_64/i686-linux-android/bin/ld.gold
sudo codesign --force --deep --sign - toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-objcopy
sudo codesign --force --deep --sign - toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-strip
sudo codesign --force --deep --sign - toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-objcopy
sudo codesign --force --deep --sign - toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-strip
References

https://issuetracker.unity3d.com/issues/unity-hub-android-ndk-integrated-ndk-version-is-not-compatible-with-available-unity-hub-or-android-developer-ndk-versions
https://forum.unity.com/threads/cant-android-il2cpp-build-on-macos-catalina.726803/

發佈留言