コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Android SDK not found

概要

If command-line tools are installed, but this message is still shown, please restart the Unity editor. 

新しい Mac に Unity 2022.3.62f2 をインストールして CLI で Android ビルドしたら
上記のメッセージが出力されてビルドに失敗する現象に遭遇した。

Android SDK not found

Unable to detect SDK in the selected directory. /Applications/Unity/Hub/Editor/2022.3.62f2/PlaybackEngines/AndroidPlayer/SDK/cmdline-tools/latest/bin/sdkmanager does not exist. Android SDK command-line tools component is not found. Make sure "Command-line Tools (6.0)" is installed in the SDK manager.
If command-line tools are installed, but this message is still shown, please restart the Unity editor. 

Unity エディタから Android ビルドしたら上記のエラーが表示された。

You are missing the recommended Android SDK Tools. Install the recommended version with Unity Hub.

Preferences を見てみたら上記の警告が表示されていた。

Android モジュールはインストールされていた。

Android モジュールのインストール先のフォルダを見てみたら
「cmdline-tools」フォルダが存在しなかった。

Unity をアンインストールしてから再インストールして
「Android SDK Command Line Tools」が正常にインストールされるのを待って

Unity インストール後に「cmdline-tools」フォルダが作成されたことを確認して
Android ビルドしたらエラーが消えてビルドに成功した。