Simulate a start up: Android Emulator - android-emulator

I coded an app which starts at the system start up and starts a service which is written in the code. The code is working fine and the service is getting started when the app is installed on a real android device but not on an emulator. I do not have a real device always handy. Any idea how to simulate a start up in an emulator?

I just found a way to simulate a start-up without having to stop-and-start the emulator. Go to the DDMS perspective (if you are using Eclipse) and "stop" the android.core process. This process respawns (you would know this if you have ever owned a HTC where that essential process seemed to stop wayyy to often) and that process of respawning will effectively reboot the emulator- i.e the BOOT event is fired.

Starting emulator simulates a boot up. Didn't know it earlier as I was missing the Toast which I had put up on the boot up for some reasons I don't know. When tried on a faster machine, the same code worked like charm. :)

Related

emulator broken: This adb server's $ADB_VENDOR_KEYS is not set

Well a windows 10 update broke sleep, the computer went to sleep with the emulator open and now that's broken. When I run an app to launch in the emulator it will boot the emulator but won't install just time out. When I try and run an app into a running emulator instance Studio says:
com.android.ddmlib.AdbCommandRejectedException: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
Error while Installing APK
I've followed some of the other threads here. I've tried changing
the environmental variable in control panel, but in fact I think it
pointed to the right place originally, where the sdks are these
days.
I've tried restarting the PC. I did try deleting a couple of
adb files, that didn't work.
I've tried deleting all the sdks and
downloading them again.
I've tried uninstalling and updating Android
Studio, several times. Now on AS 3.1, still not working.
Bit of a nightmare really.
How do I set the vendor keys? Using AS console commands? Can anyone point me to a dummies guide, this is a bit of a tangent for me, wish I could fix it from the GUI.
The working fix for this particular issue is to enable Developer options on your emulator and enable "USB Debugging".
OK so eventually downloading a nexus 4 x86 image android 27, with no play store worked. Sorry if this is repetition. Long live working emulators
Combining answers from here and there gives an answer that also worked for me in IntelliJ IDEA. I assume the issue is the same, since the emulator and AVD is the same.
Option 1:
Restart the emulator from AVD
Option 2:
Wipe the emulator data
Option 3: Stop the emulator. Then make sure it is up to date and try again.
If it still does not work, restart the adb server and retry.
adb kill-server && adb start-server
If it still does not work, perhaps your adb is out of date... somehow. This was the case for me. Running the following fixed that for me.
adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
emulator-5554 device
If it is now working for some emulators but not newly created ones, take note of the message in the emulator selection box: "Press Ok in the Allow USB Debugging Dialog"
Sadly, there is no such dialog. So go and enable Developer Mode in the settings of your emulated OS by tapping the Build Number several times. Then go to the Developer Settings and enable USB debugging.
After recent upgrades of emulator, the virtual device*) stays unauthorized. When I cold boot the emulator, sometimes I see the expected confirmation dialog, but this dialog goes away immediately, leaving no chance to click 'OK'.
We're aware of this problem and plan to fix it soon.
* Here, I was running x86 with API 28 and Google Play on Windows 10. I don't know which other scenarios are effected.
For anyone who might encounter this in the future -- I mean the ultimate issue of receiving the error, "This adb server's $ADB_VENDOR_KEYS is not set" despite not having any (or any sufficient) opportunity to click OK...
Resolution: In the Developer Settings, select the option to, "Remove existing authorized adb keys on device." Repeat the previous action -- the prompt will once again appear, as if the very first time.
-Mike
Go to developer options in your device and click on 'Revoke USB debugging authorizations'. Disconnect and reconnect your device. You'll get a prompt on your device to authorize your computer to connect to your device. click on 'OK' and your set.
Basically, the authorization key has gone out of date or it's no longer present. So, we just have to set a new autorization key and revoke the old ones.

Android Emulator starts, but it doesn't run android system

I try to run my app in android emulator. From the begining, everythigs works fine. I create new device in Android Vrtual Device Manager, then i run the device. After a while i can see an emulator with mobile skin - that's all, nothing else happens. The device has black screen and in the Android Monitor I see this:
screen from Android Monitor
When i try to run my app I recive this:
screen from selecting deployment
When I try to run app from this window, somethig is going to happen. I have to wait long long time but finally, android is started on the device but meanwhile i recive error "Session 'app':Error Instaling APK. Sometimes app will run, sometimes not, but everything works very very slow. When i run app directly (without running device from AVD Manager), app is bulided and then i see a process "Waiting fro target device to come online", emulator runs but with black screen.
I have no idea what to do now. I reinstaled Android Studio twice - always the same result.
I have to add that a few days ago everythings works perfect - very fast and without problems. Recently I was installing Ubuntu on a new partition, I've done some changes in widows driver manager. Maybe this is a reason?
What I should do now? Thanks in advance

Emulator in AMD Processor is not working

I using AMD processor. I have installed everything related to eclipse perfectly. But I'm unable to start the emulator. program is hang and keep waiting for adb forever. The same issue in android studio also. Please give a solution.
I'm using a Android Studio on an HP x360, which is a nice little laptop but has a puny processor:). I spent ages getting the Intel Hax virtual machine thingy installed on my machine, as well as configuring bios (which I found AVAST blocked changes to, so had to uninstall it).
After probably hours this week (I'm new to Android) waiting for the emulator to do it's thing, start up, load program, and eat memory, I decided to plug in my phone (Moto-e).
This has made a massive improvement! Only takes a minute to compile and run now! You also have piece of mind that your app will run in the real world.
So as a newb to Android, I'd say don't bother with the emulator.... plug a real device in.
See here for setting up HAXM, if you have trouble installing, it may be antivirus etc blocking it....
Intel HAXM
All the best.
try these threads Virtualization threads

why opening more than one Emulator while running?

While doing programs I normally use AVD Manager to open the emulator, but nowadays while I am running a program a new emulator is being opened automatically, it also takes a long time almost 10-15 minutes. Can somebody please help to avoid this problem?
If ou press run in eclipse and it cannot see a connected device, sometimes devices/emulators fail to connect to the adb daemon so even if they are open they are not connected it will automatically launch an android emulator to fulfil the request which will be the default emulator in the AVD list. The reason it is slow is because you are using an arm image and that emulator is just really really slow, what you will want to do is set up an AVD to use an x86 image, you might need to download this through the android sdk manager first if you haven't already and then follow the information at: http://developer.android.com/tools/devices/emulator.html to get it set up to work as fast as possible (HAXM, graphics acceleration etc)

MonoTouch on Device - Vibrates at launch?

I just deployed my app to my iPhone for the first time. Every time it launches it vibrates before running, and it runs fine. The build is a Debug | iPhone one of my app.
Any ideas why it vibrates when it launches and how to stop that? It's definitely not something I coded up and I don't have any exceptions or issues when running in the simulator.
The vibration happens when you build the application in debug mode, and run the application without a debugger waiting. The MonoTouch soft debugger vibrates to inform you that it couldn't find the debugger.
Running the app in Release | iPhone mode solves this.
The number of vibrations is used to notify the user of a problem setting up debugging at startup. The full list (that will be maintained as we expand or modify it) is here:
http://monotouch.net/index.php?title=Documentation/Debugging
As of today:
Device Diagnostics
An application compiled with debug mode that has been deployed on the iPhone will try to contact MonoDevelop on startup on the IP address and port that MonoDevelop had at the time of the build.
If there is an error setting up the debugger, it will vibrate one of more times:
One vibration: The application was compiled with debugging support, but it is unable to reach MonoDevelop on the specified IP address and port to setup stdout/stderr
Two vibrations: It is unable to parse the address configured.
Three vibrations: Could not setup stdout/stderr to the application.