How to build an Android APK file without using Android Studio in a Capacitor project?

Sorry to bring up this thread. I am trying to build using Capacitor for more than 12 hours now. My last attempt was


$ ionic capacitor copy android && cd android && ./gradlew assembleDebug && cd ..

It looked all good until

Welcome to Gradle 5.6.4!

Here are the highlights of this release:

  • Incremental Groovy compilation
  • Groovy compile avoidance
  • Test fixtures for Java projects
  • Manage plugin versions via settings script

For more details see Gradle 5.6.4 Release Notes

Starting a Gradle Daemon (subsequent builds will be faster)

Configure project :app
google-services.json not found, google-services plugin not applied. Push Notifications won’t work

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/home/meen/PSD/android/local.properties’.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2m 35s

I do not know what do. I have tried a lot of things but nothing worked. I am not sure how to make Android Studio work with Ionic/Capacitor. After add android , I tried opening the folder in Android Studio. It says detected framework, gradle etc. But won’t Run or Build. If possible, please help me out.

I am using Ubuntu 20.04.