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
Using Capacitor, the process is as follows:
In your Visual Studio Code project, run:
ionic build --prod
(configuration optional)npx cap sync
(https://capacitorjs.com/docs/v2/cli/sync)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:
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:
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
Did you try the Visual Code extension for Ionic and Capacitor?
https://ionicframework.com/docs/intro/vscode-extension
This might certainly ease things out 🙂