skip to Main Content

I have a ionic app that I developed using Visual Studio Code as an IDE. When I run "ionic serve" in the Visual Studio Code terminal the app runs just fine, however I need to run it on an android studio virtual device for proper debugging.
I already have a virtual device set up in my android studio installation.
So from the visual studio code terminal I ran "ionic cap build android" but it doesn’t open the android studio page, nor returns any errors, it only returns an "app running on android" message after the build is supposedly over.

Any idea what I might have done wrong?
If you do, could you explain to me in detail how the building and deploying process works for mobile apps? I’ve been trying to study the ionic and android studio documentations but I’ve been having a hard time understanding which commands to run and when. Thank you

2

Answers


  1. Using Capacitor, the process is as follows:

    In your Visual Studio Code project, run:

    1. ionic build --prod (configuration optional)
    2. npx cap sync (https://capacitorjs.com/docs/v2/cli/sync)
    3. npx cap open android (this will open your project in Android Studio)

    Note: Ensure your Android Studio and related packages are up to date.

    In Android Studio, update the version and version code in the build.gradle file (only necessary if you plan on publishing the app), ex:

       versionCode 2100001
       versionName "0.0.1"
    

    You can now build and run your app in Android Studio by selecting a an emulator or device (see https://developer.android.com/studio/debug) and clicking on the Run button in the top right of Android Studio: enter image description here

    If you wish to publish your app on the PlayStore, you need to generate and sign an APK file to upload: https://developer.android.com/studio/publish/app-signing

    Login or Signup to reply.
  2. Did you try the Visual Code extension for Ionic and Capacitor?

    https://ionicframework.com/docs/intro/vscode-extension

    This might certainly ease things out 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search