Android sdk linux avd

How to open the AVD manager on Ubuntu Linux from the command line?

For thoose coming here because the android avd command has been deprecated*, here’s how to do it now:

Using Android Studio

Open Android Studio with a valid studio project (if you don’t have one, simply create one empty). After you’ve your project open, go to Tools => Android => AVD Manager . Note that this menu does not appear if you don’t have a valid Android Studio project open.

Now you can safely close Android Studio if you only want the AVD Manager.

From command line

If you want to use the command line you’ll first need to create the virtual device using avdmanager , located under $ANDROID_HOME/tools/bin/avdmanager like so:

$ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64' 

After you created the device to emulate, then you need to open it with emulator , which is located under $ANDROID_HOME/tools/emulator . The command for the previously created device should be something like:

If it crashes saying something like.

[140022905190208]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib 

Ensure you’re running the emulator command inside the $ANDROID_HOME/tools folder, otherwise may not work.

If you already added a device VM you can list them all with

Check out the official documentation for more details (thanks to Jeff Xiao for this—in comments).

The android command is no longer available. For manual SDK and AVD management, please use Android Studio. For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager 

Источник

Читайте также:  Node js ide linux

Set Env Vars and Path

I had to do this in a few places. root, user, and sudoers.

root & user

Create a bash_alias for root, modify .profile for user. Same data in both.

~$ sudo touch /root/.bash_aliases ~$ sudo vim /root/.bash_aliases ~$ sudo vim ~/.profile # set PATH so it includes android sdk emulator if it exists if [ -d "/opt/android/emulator" ] ; then PATH="/opt/android/emulator:$PATH" fi # set PATH so it includes android sdk platform tools if it exists if [ -d "/opt/android/platform-tools" ] ; then PATH="/opt/android/platform-tools:$PATH" fi # set PATH so it includes android sdk command line tools if it exists if [ -d "/opt/android/cmdline-tools" ] ; then PATH="/opt/android/cmdline-tools:$PATH" fi # set PATH so it includes android sdk command line tools bin if it exists if [ -d "/opt/android/cmdline-tools/bin" ] ; then PATH="/opt/android/cmdline-tools/bin:$PATH" ANDROID_SDK_ROOT="/opt/android" ANDROID_HOME="/opt/android" fi # set PATH so it includes android sdk command line tools if it exists if [ -d "/opt/android/cmdline-tools/latest" ] ; then PATH="/opt/android/cmdline-tools/latest:$PATH" fi

sudoers

use sudo visudo then add the following to the Defaults secure_path=

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/android/cmdline-tools/bin:/opt/android/cmdline-tools/latest:/opt/android/emulator:/opt/android/platform-tools"

Install Android packages

~$ cd /opt/android/ ~$ sudo sdkmanager --sdk_root="/opt/android" --install "platforms;android-31" ~$ sudo sdkmanager --sdk_root="/opt/android" --install "system-images;android-31;google_apis_playstore;x86_64" ~$ sudo sdkmanager --sdk_root="/opt/android" --install "build-tools;31.0.0" ~$ sudo sdkmanager --sdk_root="/opt/android" --licenses
~$ sudo avdmanager list target Warning: Observed package id 'build-tools;31.0.0' in inconsistent location '/opt/android/build-tools/31.0.0' (Expected '/opt/build-tools/31.0.0') Warning: Observed package id 'emulator' in inconsistent location '/opt/android/emulator' (Expected '/opt/emulator') Warning: Observed package id 'patcher;v4' in inconsistent location '/opt/android/patcher/v4' (Expected '/opt/patcher/v4') Warning: Observed package id 'platform-tools' in inconsistent location '/opt/android/platform-tools' (Expected '/opt/platform-tools') Warning: Observed package id 'platforms;android-31' in inconsistent location '/opt/android/platforms/android-31' (Expected '/opt/platforms/android-31') Warning: Observed package id 'system-images;android-31;google_apis_playstore;x86_64' in inconsistent location '/opt/android/system-images/android-31/google_apis_playstore/x86_64' (Expected '/opt/system-images/android-31/google_apis_playstore/x86_64') Warning: Observed package id 'tools' in inconsistent location '/opt/android/tools' (Expected '/opt/tools') Available Android targets:==============] 100% Fetch remote repository. ---------- id: 1 or "android-31" Name: Android API 31 Type: Platform API level: 31 Revision: 1

Create AVD

~$ /opt/android/cmdline-tools/bin/avdmanager create avd --force -n Tablet -k "system-images;android-31;google_apis_playstore;x86_64" Warning: Observed package id 'build-tools;31.0.0' in inconsistent location '/opt/android/build-tools/31.0.0' (Expected '/opt/build-tools/31.0.0') Warning: Observed package id 'emulator' in inconsistent location '/opt/android/emulator' (Expected '/opt/emulator') Warning: Observed package id 'patcher;v4' in inconsistent location '/opt/android/patcher/v4' (Expected '/opt/patcher/v4') Warning: Observed package id 'platform-tools' in inconsistent location '/opt/android/platform-tools' (Expected '/opt/platform-tools') Warning: Observed package id 'platforms;android-31' in inconsistent location '/opt/android/platforms/android-31' (Expected '/opt/platforms/android-31') Warning: Observed package id 'system-images;android-31;google_apis_playstore;x86_64' in inconsistent location '/opt/android/system-images/android-31/google_apis_playstore/x86_64' (Expected '/opt/system-images/android-31/google_apis_playstore/x86_64') Warning: Observed package id 'tools' in inconsistent location '/opt/android/tools' (Expected '/opt/tools') Auto-selecting single ABI x86_64========] 100% Fetch remote repository. Do you wish to create a custom hardware profile? [no]
avdmanager list avd Available Android Virtual Devices: Name: Tablet Path: /root/.android/avd/Tablet.avd Target: Google Play (Google Inc.) Based on: Android 12 Preview (S) Tag/ABI: google_apis_playstore/x86_64 Sdcard: 512 MB

Launch emulator

Verify you can see the AVD

~$ emulator -avd Tablet emulator: Android emulator version 30.7.5.0 (build_id 7491168) (CL:N/A) PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/opt/android]!

Источник

Оцените статью
Adblock
detector