开发者

How to create a batch file to launch the emulator with the AVD in android?

开发者 https://www.devze.com 2022-12-31 18:38 出处:网络
In reference to my previous question regarding making the .EXE file for demonstration How to make .EXE for demonstration of a Android Software built in eclipse?

In reference to my previous question regarding making the .EXE file for demonstration

How to make .EXE for demonstration of a Android Software built in eclipse?

Can anyone explain creating batch file to lau开发者_如何学Cnch the emulator?


You can use the following code and save it as a batch file. All you need to do is swap out the "AVD_for_Nexus_6_by_Google" with one of your own emulators.

cd "%USERPROFILE%\AppData\Local\Android\sdk\tools" && .\emulator -avd AVD_for_Nexus_6_by_Google

If you want to see a list of all your installed emulators save and run the following in a batch file. The pause at the end is to make sure the window doesn't close when the command is complete.

cd "%USERPROFILE%\AppData\Local\Android\sdk\tools" && .\emulator -list-avds pause


you can use the following command to launch the emulator

emulator -avd <avdname>

this assumes the path to emulator is set on your system


For run test from command prompt you can use @zair-naim answer

if you find error PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT, just add ANDROID_SDK_ROOT to your Environment Variables

How to create a batch file to launch the emulator with the AVD in android?

Open new Command Prompt and run again

  1. Create batch File "run_avd.bat" on Desktop or another place
  2. Edit and Add this line of code

cd "%USERPROFILE%\AppData\Local\Android\sdk\tools" start emulator -avd Nexus5x change Nexus5x with your avd name

  1. Save file and run batch file


You can use the below code and save it as a batch file.

cd C:\Users\user\AppData\Local\Android\Sdk\emulator && emulator -avd Nexus_5_API_28


create batch file for example Pixel2.bat

and enter following commands:

set PATH="D:\Android\Sdk\emulator"  
emulator -avd Pixel_2_API_28

save the file. you can directly run emulator without opening android studio.


create batch file for example pixeldevice.bat

  • open notepad
  • put the following command

@Echo off

@Echo %cd%

C:

CD "C:\Users<may different>\AppData\Local\Android\Sdk\emulator"

@Echo %cd%

emulator -avd pixel2Emulator

Pause

  1. CD "C:\Users<may different>\AppData\Local\Android\Sdk\emulator" - navigate to emulator path
  2. @Echo %cd% -- display current path
  3. emulator -avd pixel2Emulator - run emulator
0

精彩评论

暂无评论...
验证码 换一张
取 消