Mar 10 2020 09:52 PM
Dear Team, I have been facing issues with the Duo Emulator launch with the Visual Studio 2019, as the emulator not shows in visual studio build option(<build> (Android 10.0 - API 29) ). I have followed the official instruction . So far I didn’t find any solution. Below am giving the details.
Problems
Things I done
Things that works (before modifying run.bat )
The emulator successfully launch with the Android SDK (run_androidstudio.bat:( I have already installed VS 2019 with Xamarin. And once I installed the Surface Duo emulator, I try to directly launch the emulator by clicking emulator icon, however its not respond, then I installed the android studio and tried again, and it was successfully launched.
Please advise, Thanks.
Mar 11 2020 11:21 AM - edited Mar 11 2020 12:24 PM
Hi @Sivaprasad. G ,
When I tried this I didn't hit your error but still I wasn't able to successfully connect the emulator to Visual studio.
what finally enabled me is to change the ANDROID_SDK_LOCATION in the Xamarin version from:
set ANDROID_SDK_LOCATION=C:\Program Files (x86)\Android\android-sdk (the line copied from the instructions to the same line I used when connecting the emulator to Android Studio:
set ANDROID_SDK_LOCATION=%LOCALAPPDATA%\Android\Sdk
if you changed this line to enable the emulator on android studio, please use the same location with the Xamarin script.
I have attached the version that worked for me (note that this site doesn't allow attaching txt or bat files so I pasted it into a word doc :)
please let me know if this helps.
Meir
Mar 11 2020 11:58 PM
Hello @tggmbi ,
Thank you for your prompt reply, I went through your solution and changed the ANDROID_SDK_LOCATION location as you mentioned,(same location which work with android studio) but still I wasn't able to successfully connect the emulator to Visual studio.
Sivaprasad. G
Mar 12 2020 08:48 AM
I am sorry that didn't work...
can you attach the script you are running and the script that works for you in android studio?
thanx,
Meir
Mar 12 2020 09:48 AM
Mar 12 2020 03:41 PM
thanks!,
I have compared and its identical to what I have...
Next step :) ,
can you send me the text that is in the console ?
(just ctrl-a then enter) so we can look for any errors.
Meir
Mar 13 2020 01:15 AM
Hello @tggmbi, Thank you for your prompt reply, please refer the attached file.
Mar 13 2020 05:21 AM
Maybe my fix will help you, too. :)
Please see: https://techcommunity.microsoft.com/t5/surface-duo-sdk/how-to-fix-surface-duo-emulator-will-not-star...
Mar 13 2020 06:04 AM
Hello @tscholze,
Mar 13 2020 09:42 AM
Hi @Sivaprasad. G , in the two batch files you shared above script that works for android studio.docx, the second script differs slightly from the first, in that a lot of the command line parameters are not "quoted". For example, the first one:
"%EMULATOR%" -verbose -accel auto %* -ports 5575,5579 -sysdir "%DIRNAME%\bin" -kernel "%DIRNAME%\bin\kernel-ranchu" -datadir "%DIRNAME%\bin\data" -initdata "%DIRNAME%\bin\userdata.img" -vendor "%DIRNAME%\bin\vendor-qemu.img" -system "%DIRNAME%\bin\system-qemu.img" -initdata "%DIRNAME%\bin\userdata.img" -data "%DIRNAME%\bin\userdata.img"
versus the second one:
"%EMULATOR%" -verbose -accel auto %* -sysdir %DIRNAME%\bin -kernel "%DIRNAME%\bin\kernel-ranchu" -datadir %DIRNAME%\bin\data -initdata %DIRNAME%\bin\userdata.img -vendor %DIRNAME%\bin\vendor-qemu.img -system %DIRNAME%\bin\system-qemu.img -initdata %DIRNAME%\bin\userdata.img -data %DIRNAME%\bin\userdata.img
Notice how the second one is missing "" around "%DIRNAME%\bin\data" and most of the other parameters? For most users, this does not cause an issue, but because your user folder has a space in it "C:\Users\Sivaprasad. G\" (as shown in the log file you shared), the space causes the command line to think there are two separate parameters, and you get an error:
invalid command-line parameter: G\SurfaceDuoEmulator\artifacts\\bin
which is because of the space before the G. Having quotes around the parameters that include %DIRNAME% should fix this issue with that .bat file.
Let us know if that helps?
Mar 14 2020 03:30 AM
Hello @Craig_Dunn ,
Thank you for the detail information and support , After changing the script, I can successfully launch the emulator by clicking the run.bat, However when I tried to run the sample app (surface duo Xamarin sample apps) I didn't find the Surface Duo emulator in option, (even I build, the solution )
I also tried following the steps
The same thing applied to run_vs.bat, and I can directly launch the emulator by clicking run_vs.bat
However still I wasn't able to successfully connect the emulator to Visual studio.
Mar 15 2020 06:41 AM
That's sad @Sivaprasad. G,
just as a guess, did you tried to launch VS as an administrator? Do you use any security software that may block some inner computer connections?
Mar 15 2020 10:39 PM
@tscholze Thanks for the suggestion, but i couldn't figure out the solution yet. I use the windows security.
Mar 19 2020 11:54 AM
@Sivaprasad. G That's sad. Please let us know if you found a fix! I cross my fingers for you. :)
Mar 19 2020 12:04 PM
@Sivaprasad. G after you start the emulator with run_vs.bat, can you do adb devices in the command line and confirm that the Surface Duo emulator shows up there? The Surface Duo emulator might not automatically appear in the Visual Studio menu by default, but if it is shown in the adb devices list, then it should also be available in Visual Studio.
Mar 20 2020 09:07 AM - edited Mar 20 2020 10:27 AM
Hi @Craig_Dunn ,I am unable to type or paste the "adb devices" on the command line after the emulator start, I tried many times, the run_vs.bat CMD is no more accepting any input once it started. Please advise, Thanks.
Mar 20 2020 09:09 AM
@Sivaprasad. G you can start a new command window and use adb devices there - you are correct the one that started the emulator will not accept further input.
Mar 20 2020 10:22 AM
Hi @Craig_Dunn,OK, Surface Duo emulator Is Not shown up in the list. please advise . Thanks
C:\Program Files (x86)\Android\android-sdk\platform-tools>adb devices
List of devices attached
47f020a5 device
emulator-5578 device
Mar 20 2020 11:02 AM
Solution@Sivaprasad. G if you see the Surface Duo emulator, check the port showing in the title bar (it will say something like "Android Emulator - <build>:5556").
That should match the post listed by adb devices, even though the rest of the name may not match exactly. I've attached a screenshot of how it looks for me.
I'll add that whenever I use the Visual Studio batch file (run_vs.bat), I get a low-numbered port (like 5554 or 5556). I notice in your list it's 5578. Check that your batch file does not specify the -ports parameter (and also confirm the ANDROID_SDK_LOCATION is the one in C:\Program Files (x86\Android\android-sdk).
Mar 21 2020 10:29 AM
@Craig_Dunn , Thank you so much for your valuable time and support , I successfully connect the emulator to Visual studio. For me, It took around 10 minutes to appear the emulator option in visual studio at first time. Thank you so much @tggmbi and @tscholze for your valuable suggestion ,
Mar 20 2020 11:02 AM
Solution@Sivaprasad. G if you see the Surface Duo emulator, check the port showing in the title bar (it will say something like "Android Emulator - <build>:5556").
That should match the post listed by adb devices, even though the rest of the name may not match exactly. I've attached a screenshot of how it looks for me.
I'll add that whenever I use the Visual Studio batch file (run_vs.bat), I get a low-numbered port (like 5554 or 5556). I notice in your list it's 5578. Check that your batch file does not specify the -ports parameter (and also confirm the ANDROID_SDK_LOCATION is the one in C:\Program Files (x86\Android\android-sdk).