Ionic Failed to find 'JAVA_HOME' environment variable

[15:14:04]: Shell command exited with exit status 1 instead of 0.

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Generating initial manifest for Ionic Deploy…
Ionic Deploy initial manifest successfully generated.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/opt/android-sdk (recommended setting)
ANDROID_HOME=/opt/android-sdk (DEPRECATED)
Failed to find ‘JAVA_HOME’ environment variable. Try setting it manually.

same environment i’ve been using to build android via platform, but this time it gives this error. how do i fix?

failed build: app/7b074fb3/build/builds/7904064

successful build: app/7b074fb3/build/builds/7795934

[12:47:12]: Shell command exited with exit status 1 instead of 0.

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Generating initial manifest for Ionic Deploy…
Ionic Deploy initial manifest successfully generated.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/opt/android-sdk (recommended setting)
ANDROID_HOME=/opt/android-sdk (DEPRECATED)
Failed to find ‘JAVA_HOME’ environment variable. Try setting it manually.

±-----±----------------------±------------+
| fastlane summary |
±-----±----------------------±------------+
| Step | Action | Time (in s) |
±-----±----------------------±------------+
| 1 | default_platform | 0 |
| 2 | build_summary | 0 |
| 3 | add_git_credentials | 0 |
| 4 | get_appflow_config | 0 |
| 5 | detect_native_type | 0 |
| 6 | dependency_install | 109 |
| 7 | get_web_dir | 0 |
| 8 | set_java_home | 3 |
| 9 | modify_config_xml | 0 |
| 10 | download_credential | 1 |
| 11 | build_pro_app | 179 |
| 12 | add_cordova_to_index | 0 |
| :boom: | build_android_cordova | 13 |
| 14 | upload_logs | 5 |
±-----±----------------------±------------+

[12:47:12]: fastlane finished with errors
/usr/local/bundle/bin/fastlane: \e[31m[!] Shell command exited with exit status 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError)

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Generating initial manifest for Ionic Deploy…
Ionic Deploy initial manifest successfully generated.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/opt/android-sdk (recommended setting)
ANDROID_HOME=/opt/android-sdk (DEPRECATED)
Failed to find ‘JAVA_HOME’ environment variable. Try setting it manually.
\e[0m
Running after script…
$ run “clean-up”
ERROR: Job failed: command terminated with exit code 1