Changes in Hosts file lost when not using -writable-system in Android Emulator - android-emulator

I updated the /system/etc/hosts file in Android emulator by starting the emulator with the flag -writable-system.
emulator.exe -avd tablet -writable-system
When I restarted the emulator without the -writable-system flag, my changes to the hosts file were gone.
If I restart the emulator with the -writable-system flag on, I can see my changes there and everything works as expected (without updating the file again nor remounting).
Why is this happening? Is it possible to start the Android emulator without that flag and preserve my changes to the hosts file?

Related

Android Studio device list stuck on loading

Picture of the issue
I'm trying to add my physical phone to the device list, however, the device list is stuck on loading.
I try to Kill adb process (on Task Manager on Windows) and Open Android Studio
And also I Try to reinstall Flutter and resetting the Flutter SDK, but still the same problem.
For me this fixed the issue:
First close the android studio and kill the all the related bg
processes.
Restart pc and check there are no bg processes running.
Now connect your Android Device (make sure USB debug is enabled).
Revoke the debug permissions and then allow debugging.
Now on pc run adb devices command from terminal.
If your device is displayed then proceed to open Android Studio and
wait for some time.
Also make sure that there is only one version of adb is installed.

Virtual Emulator Freeze in android studio on windows 10

I am doing my first project on android studio but Virtual emulator is freezing every time I run, it start to get black screen and showing 'no device selected' even I have open virtual emulator and its up working fine but when I run code virtual emulator wont respond.
Try running a cold boot for your android emulator. You can do this by navigating to the emulator files on your OS. If you are using Windows OS, this terminal command would look something like this:
cd C:\Users\your-account\AppData\Local\Android\Sdk\emulator>
Once you have navigated to the emulator directory, you can force a cold boot by running the following command:
.\emulator.exe -avd Your_Device_Name -no-snapshot-load
It is not clear from your question what code editor you are using, but this is effective in Visual Studio Code, especially if you have installed the Android iOS Emulator extension.

Flutter : No Devices available [duplicate]

This question already has answers here:
Android Studio, Suddenly got GPU Driver Issue when running emulator
(11 answers)
Closed 10 months ago.
Good night people !!!!
I am making settings in the Flutter Framework to use Android Studio, I already did a lot of the settings but when interpreting the flutter in the command line, do not find the device, so I went to look for the settings in Android Studio and gave a stop in the AVD Manager to Virtual Devices ... the error
GPU#1
Make: 8068.
Model: Mobile Intel (R) 4 Series Express Chipset Family (Microsoft Corporation-WDD 1.1)
Device ID: 2a42
I ask for help solving the problem. Here is the error screenshot.
Try to run the emulator via command line/terminal/cmd.
first, find the emulator list:
emulator -list-avds
then run one of it:
emulator -avd avd_name -gpu mode
If you cant find the emulator command, try to look at the executable in
c:\Users\username\AppData\Local\Android\Sdk then add the path to your environment.
try running emulator from terminal, forcing it to run using hardware graphics (instead of letting emulator decide on which) using command
emulator -avd avd_name -gpu mode
where mode is host so that it will run with hardware.
example:
Using Android Studio terminal move to folder where the emulator is located. Default on Win10 is: C:\Users\userName\AppData\Local\Android\sdk\emulator
Find emulator to run by listing available ones: emulator -list-avds
Run emulator with -gpu host option: emulator -avd avd_name -gpu host
Checkout the following path.
File > Project Structure > Project SDK
If there is NO SDK selected. Then Select Appropriate Android SDK by configuring it.
Otherwise,
In your terminal, add following command
adb kill-server
adb start-server
I hope this will definitely work for you.

How to upgrade the chrome browser version Android 7.0 emulator in android studio

I have created a Virtual Device with the Android flavor I want (Android 7.0) but it has a version of Chrome that I'd like to update to a specific version. How would I go about doing that?
For me it was simple steps:
Open Android emulator from AVD (Mine was Google Pixel 2 - v9.0),
Ensure Android emulator has opened successfully by $ adb devices(It will give you the Android emulator device name, e.g: emulator-5554)
Now download the Google Chrome apk from apkmirror, Mine was Version: 76.0.3809.111 (380911115) x86
Now use this command to install the downloaded Google chrome apk to the opened Android emulator: $ adb install /path/to/downloaded/chrome/apk
NOTE: Make sure no other emulator or real Android device is connected, $ adb devices should return you the single connected device
Above command must return Success
Open Chrome browser on Android device and check the version, it must match with the downloaded chrome version.
Done.
Having run into this and bashed thru a few useful sites, it turns out this is rather easy BUT you have to make sure you get the right APK. With thanks to https://www.inflectra.com/support/knowledgebase/kb276.aspx
First start your emulator in writable mode. Put your virtual device name after -avd parameter.
Step 1:
In Terminal execute this command:
$ $ANDROID_HOME/emulator/emulator -avd Samsung_Galaxy_S7_API_24 -writable-system
Your android emulator should now be open.
Step 2:
Download the apk you want from https://www.apkmirror.com/apk/google-inc/chrome/
Mine was https://www.apkmirror.com/apk/google-inc/chrome/chrome-64-0-3282-123-release/#downloads
Step 3:
Once it downloads, drag and drop that .apk file onto your emulator.
Wait a few minutes and then open Chrome on that device. It should be the new version.
You can confirm that by going to https://www.whatsmyua.info/

How to prevent launch Ionic app on emulator

I'm working on ionic App and I'm trying to run App on real Android device, But when I run ionic run android in terminal, I get the following error:
Running command: "C:\Program Files (x86)\nodejs\node.exe"
D:\wamp\www\pars-app\pars-app\hooks\after_prepare\010_add_platform_class.js
D:\wamp\www\pars-app\pars-app
add to body class: platform-android
ANDROID_HOME=D:\Sdk\android-sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_45
No target specified, deploying to emulator
ERROR running one or more of the platforms: No emulator images (avds)
found.
1. Download desired System Image by running: "D:\Sdk\android-sdk\tools\android.bat" sdk
2. Create an AVD by running: "D:\Sdk\android-sdk\tools\android.bat" avd HINT: For a faster emulator, use an Intel System Image and install
the HAXM device driver
You may not have the required environment or OS to run this project
How to prevent run app on windows emulator? I want to run app on real device that conected to my computer.
I am using windows 8 and Huawei with Android 4.2.2
::note
I have read these questions, But I didn't got the answer!
Why not work Ionic app testing on android real device?
Ionic run android does not run app on device
ionic run android - configurations not running app on device
As a complement to #OClyde answer, you could try :
adb kill-server
adb start-server
To have infos about these commands :
adb --help
Nb : Sometimes, for a reason i do not know, the connection between my phone and the computer break. Running this fixes it.
To make sure that your app is not installed to an emulator but to your device, take the following steps:
Open up your console and run adb devices. This should give you a list of all devices available (real devices as well as running emulators) to the Android Debug Bridge. If the adb command is not recognized check that you have installed the Android SDK correctly and that you've set all the necessary environment variables accordingly.
The adb devices command might give you output similar to this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
This indicates that the ADB wasn't ready before, so in this case just try to un- and replug your device and run adb devices again to see if the device is listed afterwards.
If your device is still not showing, check that USB Debugging is enabled on your device. Therefore you first have to enable developer settings, which you can do by tapping the build number (Settings => About Phone) 7 times (no, that's not a joke ;) ). After that, you'll have the developer options in your settings menu. Open these and check "USB Debugging"
If still your device isn't recognized by the ADB, change the USB connection mode. You can either do this in the developer options as well or tap the notification shown when the phone is connected to your PC. Try MTP as well as PTP, on of those should do the job.
After these steps, it should be nearly impossible that the device is still not recognized by your PC. As soon as there is a phone available, Ionic will install the app on the phone automatically instead of launching an emulator.