To set ANDROID_HOME and JAVA_HOME permanently on Mac OS for Ionic in 2023, you can follow these steps:
Step 1: Install Java 11. Latest version of Ionic require Java 11 instead of Java 1.8.x.
Download and Install Java 11 from this link:
Step 2: Download and install latest version of Android Studio
https://developer.android.com/studio
You need refer latest API version required by Google Play here:
https://developer.android.com/google/play/requirements/target-sdk
Only if you are using Cordova, you need also make sure Cordova support the target SDK version
https://cordova.apache.org/docs/en/11.x/guide/platforms/android/
Step 3: Edit bash profile. This is for MacOS Monterey. Different version of Mac may have different file.
sudo nano ~/.zshrc
Edit as folllow:
Step 4: Save and quit the terminal. Reopen and verify:
java -version