Problem launching Android Emulator from Capacitor App in VSCode - android

I have an Ionic Capacitor app running from VSCode, but am getting the following error when I try to launch the emulator directly from the IDE:
Multiple network interfaces detected! You must select an
external-facing IP for the dev server that your device or emulator can
access with the --public-host option.
I'm using the Ionic extension for VSCode to launch the Android emulator from VSCode, which ultimately is running the following command:
npx ionic build && npx ionic cap run android -l --external --target=Pixel_5_API_27
As shown that's a Pixel 5, using API 27. I've tried a couple of different emulators with different API versions but it behaves the same. I understand the error is indicating I need to provide a IP and port, but not sure exactly where to configure this, or if that's exactly what needs done.
This additional information is provided in the output, but also not sure where this would be configured, or as part of the command to run:
You must select an external-facing IP for the dev server that your
device or emulator can access with the --public-host option.
Note, this does work if I open my app from Android Studio and run it on the same emulator from within that IDE, so this is something specific to VSCode. Any idea on what I need to do to get this emulator to launch please?

Related

How to test and debug changes to a local AOSP build using the emulator?

I am interested in building AOSP locally and running it inside of an emulator locally. Is this possible? If so, how can one test and debug the changes locally while running the emulator? Where can one find the emulator in the build and how can one start the emulator via CLI or in Android Studio?
Would it be possible to test and debug steps starting from the App across Android App (Kotlin/Java), Android Framework (Java) and Android HAL (Native)?
Android AOSP supports running emulators in the form of AVD (Android Virtual Device), give it a read here:
https://source.android.com/docs/setup/create/avd
You need to sync AOSP as usual and then select the correct product in the lunch menu, for example, sdk_phone_x86_64 . When you run make, at the end of the successful build you just need to pass the command $ emulator and the image should bootup. Please go through the link shared.
Debugging should be available via ADB.

How do i run my ionic android app on an emulator without installing/running the android studio?

Android studio is too heavy and slows down my pc for development. i am an ionic developer and i only need the android emulator to have a better test environment for my mobile application. I only make use of the android studio because i am trying to set up the virtual emulator following the steps in this video Ionic 3 Tutorial #16 Run app on Android Emulator
I will like to know if there is another way out to test and run my ionic app either on a real or virtual android emulator. I will like to know if i can run the emulator through my vs code or a lighter IDE
If you have set up the emulator already it is enough to execute "ionic cordova run android" in Visual Studio Code.
VSCode than checks for physical devices connected. If not, it will take the emulator.
Or you could use another emulator like Droid4X or BlueStacks.
=> Build the APK (ionic cordova build android) and install it on one of those.
One option might be use ionic serve to run it in the browser then in the console activate Toggle device toolbar is not android emulator but might be useful for mobile debug.

No target specified and no devices found, deploying to emulator on running Cordova run android on Mac to an Android device

I am using Cordova and want to debug the app on my Android device.
When I am plugging the device I have to accept MTP permission - I did so.
I also enabled developer USB mode in the device settings.
When I run the next command:
cordova run android
The app is getting installed in the device in 50% success rate.
I don't know why, but sometimes its just working and the app pops up and sometimes its just not working.
I have tried to reconnect the USB, after 10 times of doing so, it works and then again start to get corrupt.
It's a new brand original samsung cable that I am using.
I am using Android file transfer in my Mac in order to make this working (without this, it does not working at all).
I have two questions, one related to Cordova and one related to the Android device USB:
How to make the device reachable for the Mac so I can transfer data without interruptions?
Is there any option to tell Cordova to build WIRELESS? I know it's possible using Ionic with --livereload flag. However I don't use Ionic with this project.
I have tried to do cordova run android -- --live-reload (in the cordova project) but this doesn't really doing something - it does not response when there is change in the build or something.
You already enable development mode. You are facing 50% success rate. I didnt get your main issue.
I have suggestion and step which you can follow to make work as I always do.
Step 1) Enable development mode
Step 2) Authenticated the connect device.
- When you connect first you will get authentication confirmation in device.
Step 3) Check connected or not(most recommend command when you connect, just cross chekc and sometime this command properly your device by starting adb server which is required to run application in android)
adb devices
(Open terminal and typpe this command)
Note : Make sure connected device show in terminal and authenticated.

NativeScript won't run local build from Sidekick

I freshly installed Sidekick for NativeScript.
When I press "Run on Device" button application throws
"Your system is not configured for local builds"
Weirdly running the app from cmd with tsc run command works perfectly and application compiles and even start on my device with no problem. This is probably something with Sidekick. I tried to reinstall app and even create fresh project.
I'm running on Windows 10 using Android SDK 25 and have libraries on version 5.0
Did anyone had the same problem?
It's most likely because you havent set up your machine for local builds although Sidekick is supposed to help automate that.
Try this:
run tns doctor in your cmd at elevated permissions and select
configure for local build when prompted or any of the options that appeal to you if you change your mind.

Can I select a particular Android Device Emulator from AVD using Apache Cordova?

Is there a way when using Cordova CLI to select a particular emulated device from the Android Device Manager (AVD)?
I am working on a tablet app and a smartphone app at the same time and need to switch to different types of emulators because of the different form factors and screen resolutions?
I know it's not a particular coding question but perhaps there is some Cordova code I can run in terminal to make the emulation more specific rather than:
cordova emulate android
Which seems to pick the first emulator off the stack.
Use the target parameter like this:
cordova emulate --target=emulator-5554 android
To get the device name of your emulator ("emulator-5554" in this example), run /platforms/android/cordova/lib/list-started-emulators.bat
If you run the following command you will get a list of all available devices:
cordova run android --list
Next you can emulate your app by running:
cordova run android --target="<Device_Name>"
For me:
If you use OSX, you can open shell in /platforms/android/cordova/lib/ as stated, and write the next command:
./list-emulator-images
after you've gotten the emulator image name,
cordova emulate android --target="the name"
*Moderators rejected my edit and said I should share as answer so -
On Linux (from your project folder) use the command:
/platforms/android/cordova/lib/list-started-emulators
(Note that there's no .bat in the command), then look for the console output e.g. emulator-5554. Then as above run:
cordova emulate --target=emulator-5554 android

Categories

Resources