How to create an emulator without using the ide?

Asked

Viewed 922 times

3

I need to emulate android on my machine, but I did not want to use a virtual machine because it would use many features, wanted to use sdk tools android studio, but also did not want to install android studio for this.

So I downloaded the sdk tools on the android studio website and tried to run, in the old versions had a Gui and it was very simple to create and run, but in the current version has not, it is all via command, I tried to run some but none was successful.

I executed that:

C:\Users\Futurotec\Downloads\sdk-tools-windows-3859397\tools>android
**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invalid or unsupported command ""

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk

So I tried running android create Avd command:

C:\Users\Futurotec\Downloads\sdk-tools-windows-3859397\tools>android create avd
**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invoking "C:\Users\Futurotec\Downloads\sdk-tools-windows-3859397\tools\bin\avdmanager" create avd

Error: The parameters --package, --name must be defined for action 'create avd'

Usage:
      avdmanager [global options] create avd [action options]
      Global options:
  -s --silent     : Silent mode, shows errors only.
  -v --verbose    : Verbose mode, shows errors, warnings and all messages.
     --clear-cache: Clear the SDK Manager repository manifest cache.
  -h --help       : Help on a specific command.

Action "create avd":
  Creates a new Android Virtual Device.
Options:
  -a --snapshot: Place a snapshots file in the AVD, to enable persistence.
  -c --sdcard  : Path to a shared SD card image, or size of a new sdcard for
                 the new AVD.
  -g --tag     : The sys-img tag to use for the AVD. The default is to
                 auto-select if the platform has only one tag for its system
                 images.
  -p --path    : Directory where the new AVD will be created.
  -k --package : Package path of the system image for this AVD (e.g.
                 'system-images;android-19;google_apis;x86'). [required]
  -n --name    : Name of the new AVD. [required]
  -f --force   : Forces creation (overwrites an existing AVD)
  -b --abi     : The ABI to use for the AVD. The default is to auto-select the
                 ABI if the platform has only one ABI for its system images.
  -d --device  : The optional device definition to use. Can be a device index
                 or id.

I tried several parameters, but none created the emulator.

I also tried to use the direct avdmanager command, but it presented the same messages.

In all my searches only found solutions that it was necessary to open android studio or that the commands were of the old versions.

1 answer

3


TL;DR

A valid command example to create an Avd:

avdmanager create avd -n "Meu-Emulador" -k "system-images;android-26;google_apis_playstore;x86"


avdmanager

The program used to create Avds is the avdmanager. It is located in sdk/tools/bin/avdmanager. The android would also work, but he ends up using the avdmanager underneath.

For the creation of an AVD two parameters are mandatory:

  • -n or --name to appoint the AVD
  • -k or --package to indicate which system image will be used

System images

For the creation of Avds is obligatory specify a system image. To list installed images, use the same command without the parameter -k:

avdmanager create avd -n "Meu-Emulador"

If no image is listed, it means that none has been installed. Installing new images can be done by using sdkmanager.

To list available packages:

sdkmanager --list --verbose

Note: the --verbose was used to not truncate package names.

To install an image:

sdkmanager "system-images;android-26;google_apis;x86"

Running Avd in emulator

To start the emulator, use the program emulator, located in sdk/tools/emulator, informing the name of the AVD to be executed:

emulator -avd "Meu-Emulador"
  • Can I list what I can add in the "-k" parameter? I copied your command exactly and presented the following message "Error: Package path is not Valid. Valid system image paths are:", and how do I download the platforms?

  • 1

    Rotating the command without the parameter -k, it will list all available Packages. The Packages are basically the system images that are in the folder sdk\system-images. In my case I have the briefcase sdk/system-images/android-26/google_apis_playstore/x86 with an image, which ends up "turning" the package system-images;android-26;google_apis_playstore;x86

  • I ran "avdmanager -k", and presented the following message: Error: Flag '-k' is not a Valid global flag. Did you Mean to specify it after the Verb/Object name?

  • 1

    It’s the other way around without the -k. Ex.: avdmanager create avd -n "Meu-Emulador". So it will list the Packages (if they exist).

  • did not appear, is it because I have none, and has to download using the commands also?

  • I have two folders here with sdk, a "virgin" and another that I use in android studio, the one I use in android studio appears the Packages when I run the command, but in "virgin" no, there is no way I download the Packages in virgin? I need to put the sdk without android studio in another machine, then I need to do this process from scratch.

  • 1

    sdkmanager --list --verbose lists all available SDK packages for installation. System images are named starting with system-images;. To install some, just call the sdkmanager again passing the package name: sdkmanager "system-images;android-26;google_apis;x86"

  • I created, but at the time of running displays the following message: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

  • Your error is already outside the scope of the question. This message indicates that there is an error in the sdk configuration or something similar. Relevant link

  • That’s right, just one last question before you mark your question as the right one, because you put "TL;DR" in the title?

  • The machine I created in android studio ran normally, but the machine created with this command, presents this error: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

  • 1

    tl;dr means too long; didnt read`. It is usually used to highlight a general summary or the most important point of the entire answer.

  • Regarding the error: from a look at the link, it has several probable causes and solutions. The fact that you are using two different sdks with different packages installed may be influencing.

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.