0

When I run the following command :

c:\SDKs\android\cmdline-tools\8.0\bin\avdmanager.bat -v create avd -n android13 -k "system-images;android-33;google_apis;arm64-v8a"

I receive the error :

[=======================================] 100% Fetch remote repository...
Error: Exception during AvdManager initialization
Error: null
expected a non-null reference

What is going wrong ?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
zeus
  • 12,173
  • 9
  • 63
  • 184

2 Answers2

1

Complete Re-edit -- This answer is based on the Android Dev Docs on how to start the emulator from the command line, the avdmanager and the sdkmanager, and now also considering an old Readme file of mine, this Stackoverflow thread and this guide.

Used the paths as in your question, adapt at need.


(1) -- Download and install an image for Android 13 (API Level 33) on arm64-v8a ABI with the command:

c:\SDKs\android\cmdline-tools\8.0\bin\sdkmanager.bat --install "system-images;android-33;google_apis;arm64-v8a"

If you're not sure which image to use, check for a list of installable images with:

c:\SDKs\android\cmdline-tools\8.0\bin\sdkmanager.bat --list | findstr "system-images"

(2) -- Create the AVD with

echo "no" | c:\SDKs\android\cmdline-tools\8.0\bin\avdmanager.bat create avd -f -n "android13" -b "arm64-v8a" -g "google_apis" -k "system-images;android-33;google_apis;arm64-v8a"

with -f|--force to enforce the creation (esp. to overwrite an existing one of same name), -n|--name for the AVD's name, -b|--abi to specify the target ABI, -g|--tag to specify the sytem image's tag, and -k|--package to provide the system image's path.

Using all this options avoids auto-select choices and such reduces the probability of corresponding failures.

Krokomot
  • 3,208
  • 2
  • 4
  • 20
  • Thanks, but that didn't help, I already did all of this :( – zeus Dec 19 '22 at 06:40
  • Hm. Is `"system-images;android-33;google_apis;arm64-v8a"` in your `sdkmanager --list` at all? And if yes, are there for the configuration `"system-images;android-33;X;arm64-v8a"` other variants than **X** =`google_apis`? – Krokomot Dec 19 '22 at 07:45
  • yes system-images;android-33;google_apis;arm64-v8a is in my sdkmanager --list and only system-images;android-33;google_apis;arm64-v8a : system-images;android-33;google_apis;arm64-v8a | 6 | Google APIs ARM 64 v8a System Image | system-images\android-33\google_apis\arm64-v8a – zeus Dec 19 '22 at 09:24
  • Completely re-edited the answer and deleted my last 3 comments as obsolete. – Krokomot Dec 21 '22 at 06:52
  • thanks Krokomot for your help! the problem was that i missed cmdline-tools\latest\bin in the path :( – zeus Dec 21 '22 at 22:38
  • Alright, good to know for myself. – Krokomot Dec 21 '22 at 22:46
1

Android Studio on Windows now defaults to PowerShell:

cd .\cmdline-tools\latest\bin
.\sdkmanager.bat --list
.\avdmanager.bat -v create avd -n android13 -k "system-images;android-33;google_apis;arm64-v8a"

Directory cmdline-tools\latest\bin could also be added to PATH.

Or to install: cmdline-tools;latest

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • it's glorious! how did you know that cmdline-tools\latest\bin must be in the path ? anyway thanks ! – zeus Dec 21 '22 at 22:37