How to get x and y coordinates of mouse over.
I have a service in android and which is connected to .net application via eneter messaging framework. I wants x and y position of mouse from service. I want mouse positions not only on clicks but also on mouse over.
Many thanks
Maybe not a best solution but atleast it works.
Both solutions are based on Genymotion emulator.
Solution #1
You need to install Genymotion emulator.
Run emulator from VirtualBox app, wait a bit until you see a few lines like "init: untracked pid ... exited"
Run the same emulator from Genymotion launcher.
Now you can simulate mouse by moving it in VirtualBox app window (not genymotion window).
Depends on how long you wait before you do step 3, android can appear in genymotion or virtual box window.
Solution #2
You need to install Genymotion emulator.
Run VirtualBox app, go to your virtual box "android emulator":
Settings -> Display -> Remote Display -> Check Enable Server
Run android emulator through the genymotion launcher.
Connect to your virtualbox with:
$ rdesktop -a 16 localhost:3389
While you move cursor in rdesktop, you can see pointer in genymotion android emulator window. Now you can intercept hover events.
There is maybe a better solution - disable mouse integration for virtual machine, so, virtualbox can grab mouse cursor, like:
$ VBoxManage modifyvm "your-vm-name" --mouse ps2
but it doesn't work for me, maybe genymotion launcher overrides settings on every launch?
Links:
http://developer.android.com/reference/android/view/View.OnHoverListener.html
p.s. hover events are available starting from api 14.
You can also use Android x86 in Live CD mode (or install it in dual-boot with Windows).
Related
I created a virtual device using Genymotion. I want to test an app that works with shaking the device. How can I make virtual device shake? I couldn't find how to shake that device.
⌘+m is working for OSX, Also Its working in Genymotion, for windows users willing to perform a shake gesture just use Ctrl+m
This method only work api under 15
For test accelerator and other like gravity,gyroscope,... can use this application.
First download sensorsimulator
This is 2 application. One install(SensorSimulatorSettings-2.0-rc1.apk) in emulator second(sensorsimulator-2.0-rc1.jar) run in your PC.
More info and full tutorial
Genymotion not support this feature :
More info Genymotion Shell
Other way :
You can use Android Studio emulator Android 6.0(Google APIS) x86.
This this emulator(All x86/x64 bit) very fast and support all sensors.
Like this:
There isn't a native way to emulate a shake in genymotion, but you could try a tool like Frappe (Mac only) to send a shake action to the virtual device. Depending on the client you are trying to emulate, "adb shell input keyevent 82" may send a shake action, wake the device, or simulate a menu key press.
For Genymotion in particular for windows use Ctrl+Shift+M.
I create a blank cordova application in visual studio 2015 and start debugging with the visual studio android emulators (first with the lollipop and then kitkat). XDE starts and the screen displays OS is starting.... It stays like that for quite a while until it displays
The emulator is unable to connect to the device operating system;
The device did not response to the connect request.
Some functionalities might be disabled'
After closing the dialog, it stays there forever until I kill the emulator. Killing the emulator triggers an error from visual studio.
Could not start emulated device 'VS Emulator Lollipop Phone'.
When I open hyper-v, I see the vm in the list and shown as running. When I connect, I see the console screen as below
I know this issue has been around for a while now, but I have just found a new solution for people who may still encounter this issue...
I had the same issue (stuck on "OS Is Starting") for API v 21 & 22. API v23 images would start, but could not debug - the app would crash as soon as it launched.
The following fixed the issue:
Shut down the emulator
Open Hyper-V manager
Go to the settings for the Android Image
Expand the "Processor" configuration node
Go to the "Compatibility" node
Check the "Migrate to a physical computer with a different processor version" option
Apparently it has something to do with newer Processor architectures being incompatible with the Android images or something like that - don't really care, as long as it works :)
I was running into the same issue. I did try to disable OpenGL by deleting: GuestDisplayProvider = "VsEmulator.OpenGLGuestDisplay" in xdesku.xml, as suggested in other answers.
At first, the virtual machine would boot up (you could connect to it from Hyper-V manager), but the emulator window itself would not connect to the machine (stuck on "OS is starting", then failing after a looooong while with the following message: "The emulator is unable to connect to the device operating system: Couldn't auto-detect the guest system IP address. Some functionality might be disabled.")
This answer https://stackoverflow.com/a/31698124/1010492 and that one https://stackoverflow.com/a/14402740/1010492 helped me solve the connectivity issue, and I was able to have the Virtual Machine displayed inside the emulator window.
However, the emulator wasn't working properly (scaling issues, no Home, Back, etc. buttons) until I put back the line "VsEmulator.OpenGLGuestDisplay" and after removing my profiles and rebooting a number of times.
To sum up, if you are encountering the same issue on an Hyper-V enabled computer, you may want to try the --over conscious-- following steps:
Ideally, uninstall any other Virtualisation software such as VMWare, Virtual Box and VPN clients such as Cisco VPN (if you cannot
do that, please be vigilant at step 13)
Reboot
In the "Visual Studio Emulator for Android" dialog, delete all installed device profiles
Remove All Hyper-V virtual switches - go to Hyper-V > Virtual switch manager > Remove all virtual switches
Run XdeCleanup.exe (usually in "C:\Program Files (x86)\Microsoft XDE\10.0.10240.0")
Also remove any extra virtual network adapters left in "Control Panel > Network and Internet > Network Connections" (after following
the previous steps, you should normally be left with only physical
adapters)
Make sure Network Sharing is disabled on all network adapters (right click, Properties, Sharing, untick "Allow other network users
to connect through this computer's Internet connection")
If ever you deleted the line GuestDisplayProvider="VsEmulator.OpenGLGuestDisplay" in xdesku.xml
(usually in "C:\Program Files (x86)\Microsoft
XDE\10.0.10240.0\SKUs\Android"), NOW IS A GOOD TIME TO PUT IN BACK.
Reboot
You may want to try to repair the emulators: go to Programs and Features > Microsoft Visual Studio Emulator for Android > Change and
hit "Repair" (although I have to say this always fails for me)
Reboot
Open the Visual Studio Emulator for Android, and install then run one of the profiles (eg: 7'' KitKat (4.4) XHDPI Tablet -- Similar to
Asus Google Nexus 7)
It may already work, but if not you should make sure that your network adapters are setup properly. Stop your emulator, then Go to
Control Panel > Network and Internet > Network Connections, and right
click the vEthernet adapters, then Properties and make sure you only
have the following boxes ticked in the Networking list (as explained
in Interference from other virtualization or networking software and
drivers: Client for Microsoft Networks, QoS Packet Scheduler, File
and Printer Sharing for Microsoft Networks, Microsoft LLDP Protocol
Driver, Link-Layer Topology Discovery Mapper I/O Driver, Link-Layer
Topology Discovery Responder, Internet Protocol Version 6 (TCP/IPv6),
Internet Protocol Version 4 (TCP/IPv4)
Reboot
Try to start the emulator again in "Visual Studio Emulator for Android"
If it still doesn't work, try to delete and recreate the profiles, and loads of reboots...
There are probably some redundants steps here, but I think it covers everything you should try (the key seems to be making sure that the network adapters are setup properly). If I've missing some things or if you think some steps are useless, please comment.
After alot of searching I got this working. Hope this helps. I found it in the comments on MSDN Article for Android Emulator with Visual Studio 2015
The new images might work if you disable OpenGL by going to Program Files (or Program Files x86 if you're on a 64-bit machine) \ Microsoft XDE \ 10.0.0.0 \ SKUs \ Android \ xdesku.xml and deleting this line: GuestDisplayProvider = "VsEmulator.OpenGLGuestDisplay". However, without OpenGL turned on you will not be able to take advantage of many of the new features
On my system I got it working again after enabling the disabled vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch) again.
I didn't have to reboot.
I went through the steps in #Gyum Fox answer and still no joy for me.
While the Visual Studio Emulator for Android creates the first emulator instance, several virtual network switches are also created. For a laptop, typically three vEthernet instances are created; one for the wired LAN, one for the Wi-Fi, and another internal virtual switch for guest to host connections.
In my case, the vEthernet for the wired LAN was created successfully and then the Visual Studio Emulator for Android process would hang. This is observable from the Hyper-V Manager and the Virtual Switch Manager action.
Using the Virtual Switch Manager I successfully created the missing Wi-Fi virtual switch with these steps. Well, ultimately it worked. Read on.
Under the Virtual Switches list, select New virtual network switch…
Under What type of virtual switch do you want to create?, select External.
Under the External network: drop-down, select the Wi-Fi adapter.
Click the Create Virtual Switch button.
Change the Name: to match the name of your Wi-Fi adapter.
Click the Apply button.
In my case though, after clicking Apply, a failure message indicated the Wi-Fi adapter was bridged. Hmmm.
I started the View Network Connections control panel applet and the Wi-Fi adapter did not show it was bridged. (When a network bridge exists, the Status column has the word Bridged appended.) I suspect there was some dusty digital bits lurking somewhere in the registry.
Here is what cleared the issue for me.
Right-click on the Wi-Fi device.
Select Add to Bridge.
Right-click on the Wi-Fi device, again.
Select Remove from Bridge.
Now, go back up to the steps to create the virtual switch for the Wi-Fi network. The steps should complete successfully now.
And now, you can go back to creating the Android emulators you want.
One final thought… If you aren’t seeing any virtual switches being created, I suspect that could mean the wired LAN might have the dusty digital bits hanging you up. In that case, I’d try add-and-remove-from-bridge trick on the wired LAN adapter to see if that clear things up for you.
And, now I suppose that just doing the add-and-remove-from-bridge trick on the network adapter without creating the virtual switch might suffice. For me, the creation of the virtual switch was proof that the issue was corrected. YMMV ;-)
I found my issue was related to the windows firewall with some enterprise policies my company applied to all PCs. Once I stopped the Windows Firewall service it worked just fine.
I also had this issue and it was not just for android emulators but for all windows phone emulators.
This is what i did to fix the issue
Uninstall the Genymotion and Virtual Box (I had these in my system and this did not solve the issue)
Removed all Virtual adapters. this is the tricky part. None of adapters could not delete from Hyper-V virtual Manager. I had to use powershell and run
remove-vmswitch -Name "The name of V Adapter" -force
Also, from this I was not able to delete all the adapters and I found this link "https://social.technet.microsoft.com/Forums/windowsserver/en-US/e49df568-4f4c-47b7-b30c-952d1e26ca58/cant-remove-failed-virtual-switch-from-hypervs-virtual-switch-manager?forum=winserverhyperv" and deleted all virtual adapters
reboot the computer
After this there was not any v adapters in Hyper-V virtual Manager
Run the XdeCleanup.exe (just in case)
Also, I disabled the firewall from my virus guard
After this I was able to run the emulator from "Visual Studio Emulators for Android"
I'm adding a separate answer though the insight provided by Gyum Fox provided the clues I needed to try other stuff ...
[NOTE: The last time I was able to use the emulators (~3 weeks ago) I had wireless disabled and was using a wired connection on my Dev laptop. I ran out of space on my switch so re-enabled the wireless as the sole connectivity option. This may be totally coincidental, but read on and I'll let y'all decide.]
After following Gyum's steps without success, I decided to turn off the wireless and then try launching the emulator.
Wouldn't you know it ... it worked without an issue! 8-}
Once I had the emulator running, I re-enabled the wireless and the emulator picked up the connectivity.
I'm not a network guy so I'm not even gonna attempt to understand. It's a minor PITA but hey ... if it works!!! ;-}
On my machine I could start the emulator but I got an OpenGL error when trying to deploy and debug. I realized my issues started after I installed Docker. On a whim I decided to shut down Docker and disable the vEthernet (DockerNAT) Network Connection. This fixed my issue. Now, whenever I need to use the Andoird emulator I have to shut down Docker. Then when I'm done debugging I enable/restart Docker.
One of the reason I was having this issue is that I did not install the Android SDK on the default location. So I had to follow these instructions in order to be able to debug my application: https://msdn.microsoft.com/en-us/library/mt228282.aspx#ADB
I had to create the folder "Android SDK Tools" and add the Key "Path" with the value to my SDK, which in my case it was "E:\Android\Android_SDK"
I have a very specific problem. I am trying to create an Android app for educational purposes, together with a friend of mine. The problem is, my processor does not support VT-x, which is essential for using an AVD, and my Android phone is considerably old so it can't really take much.
Therefore, the one solution I have in mind is using VirtualBox to create a 32-bit Android Virtual Machine and test my app there.
The problem is that, unlike an actual Android device and an AVD, a VirtualBox Android VM does not have, for what my knowledge is, an obvious way of being connected with Android Studio for testing each new app build.
So, what I am asking for is exactly that: a way to immediately test the app I have written in Android Studio in my Android Virtual Machine I have created on VirtualBox, including any workarounds that effectively allow me to immediately test the app on the VM, other than finding a way to make adb work with it.
I see I'm a bit late on this one but I figured it out. I am using Windows 8, running Android x86 (4.4 r1) on VirtualBox.
1. Set up a Host-Only adapter so that the VM has access to your network; You can set this up only when the Android image is off. Basically just go into your settings, click on Network, and select Host-Only Adapter in the drop-down labeled Attached to. For Adapter Type select PCnet-FAST III. Check the box next to Cable Connected if it isn't already.
2. Set up an NAT Adapter by selecting a different Adapter tab and for Attached to select NAT. For Adapter Type select PCnet-FAST III again. Check the box next to Cable Connected if it isn't already.
3. Enable Developer Mode by starting up the Android image, then going to Settings > About phone/tablet > Build Number. Click on Build Number 7 times. You should see a pop up that tells you how many more times you need to click to get into Developer mode. Credit to RMP PianoTuning's answer below
4. Get the virtual Android's IP address by going into Settings > About phone/tablet > Status > and then scrolling down until you find your local IP Address. Remember this number, you'll need it for the next step.
5. Start up Android Studio and go into the console; it should be one of the options in the bottom-left corner. Type in adb connect (IP address from step 4). Take a deep breath and hit enter. If it says
connected to (IP address)
you are ready to rock! When you run the app within Android Studio, your virtual Android should appear as Innotek GmbH VirtualBox, or something like the same. Select that puppy and enjoy your new, easy-to-test-on emulator. Its even Bluetooth Compatible! (but thats a whole 'nother story... google it)
Now a virtualbox isn't an answer to your need.
here are some alternatives,
Genymotion http://www.genymotion.com/ which is an easy to use android emulator , i suggest you look into it. based on virtualbox , can be integrated into android studio with ease . needs an AMD-V proc if not a VT-x . If the processor does not support these, the emulator still works, but your emulated device will only be able to use one CPU.
The other option is adb over wifi, which will let you use your phone without doing the dropbox step http://forum.xda-developers.com/showthread.php?t=1685736. For this to work you will need root though.
I was able to follow OMiKeY steps and get my app to run in VirtualBox,
the part he leaves out:
In your Android simulated device, you have to enable Developer mode.
Goto 'Settings' -> About Phone/Tablet->Build Number.
click on Build Number 7 times.
For me I got pop up that told me how many more times I needed to click to get into Developer mode.
After that i re ran the adb connect XXX.XXX.XXX.XXX command
Here's how it works for me.
I just connect my android phone with USB to my host (Windows 10).
Then make sure the USB phone is found from within the guest OS (ubuntu desktop 18.04 in VirtualBox 6.0). (VirtualbBox app: Devices > USB > check the USB corresponding to my phone). Once it's recognized by ubuntu, there will be a phone icon showing up on the desktop screen.
Next, I start android studio (v3.3.2); once that is complete, from the Terminal window (Android studio: View > Tool Windows > Terminal), I type in: adb devices, which would list the devices attached and my phone is on the list.
Now I run the app for a test (monitor my phone and confirm if there's prompt)...and the app shows up on my phone. Hope this may of help for others.
If you are running Windows, open the specific port in Firewall. In VirtualBox in your Android instalation Settings->Network Adapter 2 Tab - Port Fowarding and create a rule with Protocol (TCP) - Host IP (Your IP) - Host Port (in my case 5555) - Guest IP (Same Step 4 - Check your IP ) - Guest Port (I put the 5555 too). Ok! Now I can run my Apps in VM.
AppData\Local\Android\Sdk\platform-tools>adb connect 192.168.0.101
connected to 192.168.0.101:5555
Running devices:
innotek GmbH VirtualBox
:-)
I'm basically trying to do this:
Changing the Android emulator locale automatically
Everything works up until 'start'. the emulator starts to boot but keeps loading at the shimmering 'ANDROID' screen forever. I must be missing something... How can I restart the emulator from ADB?
Okay, I should be more specific.
I am trying to do this from the command line using adb. I can use adb to setprop and I can stop the emulator. When I try doing 'start' in the adb shell, the emulator does begin to boot, but it never returns to the lock screen.
In Android Studio go to:
Tools > Android > AVD Manager
Select your emulator device
Click "Cold boot now" to restart, or "Wipe data" to factory reset
you can try
emulator #avd_name -no-snapshot-load
it will clean load the device it worked for me.
You asked how to restart the emulator from ADB. But the title is framed in a way that pops the question up when searching about restarting it from the UI as well.
One option could be (but it depends on which tooling you are using and may not be available for all emulators/environments) is to tap and hold the Power button and then a menu will pop up with a Restart option in it.
This was a long-standing default behavior, but since Android 12 / API 31 it tries to open the Google Assistant instead (even when there's no such thing on emulators without Google APIs or Google Play 😵). The old behavior can be reverted by going to Settings > System > Gestures > "Press and hold power button" to bring up the menu in the screenshot.
To restart a running emulator I used
adb -e reboot
(Assuming there is only one running)
I'm pretty sure this will work:
Clear/Wipe the AVD to defaults or create a new one.
Start the AVD/Emulator from the CLI with the following command
emulator -avd my_avd -prop persist.sys.language=en -prop persist.sys.country=GB
change as needed. That way you are not messing with the system image which can cause hangs/crashes. And you can easily set it on boot for a variety of Locales.
If you are using Android Studio, you can goto the AVD Manager, Under Actions select "Cold Boot Now" to restart the emulator. This would get rid of errors/discrepancies which might occur if the simulator's process has been abruptly closed/terminated.
For me, kiran-chenna's answer failed me, and the solution was to instead run:
emulator -avd Pixel_2_API_28 -no-cache
In my case, a cold boot was required after the emulator got stuck. It can be found in the Android Virtual Device Manager.
on Android 13, when you swipe down to the notifications, and swipe down again, you get a power off button on the bottom right:
which has the Restart option:
Follow the following steps to restart/cold-boot your virtual device:
Open Android Studio
Click on Configure
Click AVD Manager
Click on the Dropdown on the right hand side of the virtual device.
Click on Cold Boot Now
You're done! The device will restart within a couple of minutes.
2022 Android Studio Bumblebee: With the emulated device open on screen (the "Emulator" tab open), press and hold the power button at the top of window just as you would on a real device, and it will pop up the device's menu just as if you had held the button on the side of a real device. For example:
If the power button (top left of Emulator) is opening up assistant:
Tell/type to Assistant to open "Settings" (or double drag down the battery/antenna icon on top right)
Search for "Power"
Go to "Power Gesture"
Turn that off!
To start/stop or restart emulator follow these steps:
using telnet on windows machine
or localhost 5554
avd start start
or
avd start restart
or
avd stop
Some versions of the emulator (android-7) are buggy and just hang at the shimmmera.
Try restarting it with "wipe user data" option (yes, you will have to re-run your
app or at least reinstall it).
You can try this
emulator #avd_name -no-snapshot-load
or else Simply delete the existing AVD and try to create a new one.
By following the steps.
In Android Studio > Tools > Device Manger > Create Device
you can restart the emulator from adb shell,
start the emulator and also adb shell in the terminal.
start Starts (restarts) an emulator/device instance.
stop Stops execution of an emulator/device instance.
in eclipse in the top most right u will find DDMS go i there, left side you will find Devices and in that in the last you will find a triangle downwards press that in that you will find Reset adb.
I'm trying to run the very simplest app on MonoDroid though the MonoDevelop IDE - i.e. the one that is created as part of the new project (the one that increments the lable on button clicks - i won't post code as I don't think it is relevant unless someone really wants it).
When I press the run menu item then run (or debug) i get the emulator selection
I dutifully start the emulator - (I've tried API_7, API_10, API_12) and that works OK. But the IDE above never refreshes to show the currently running emulator so I can't launch the application. I have manually refreshed but the same list comes up. What I am expecting is the new emulator to appear in the list and the OK button becoming active.
I have tried running adb devices in the command line and I can see that the debug bridge has picked up the device i.e. it says emulator-5554 which matches the TCP/IP port that the emulator is running on.
I've also tried restarting the debug server i.e.
adb kill-server
adb restart-server
But I can't see the emulator appear on the above dialog. The debug server is running on port 5037. Could the IDE be listening to a different port?
Fundamentally I'm trying to get the simplest app running through MonoDevelop. And I'm failing. Please help good people.
I had the same problem initially when I tried running the emulators. My recommendations from my own experience would be to:
Run the Android SDK manager and retrieve all the latest SDK packages.
Create your own Android Virtual Device via the AVD Manager rather than running those that are listed when the IDE is intially run. You should then start the AVD manually via the AVD manager and ensure it is fully loaded before starting the de-bug.