Reputation: 336
Prerequisite
How to reproduce :
cordova build android
cordova emulate android --verbose
Expected result
The emulator is launched.
Obtained result
Command finished with error code 0: /Users/gamecube/Desktop/geocars/platforms/android/gradlew cdvBuildDebug,-b,/Users/gamecube/Desktop/geocars/platforms/android/build.gradle
Built the following apk(s):
/Users/gamecube/Desktop/geocars/platforms/android/app/build/outputs/apk/debug/app-debug.apk
No scripts found for hook "before_deploy".
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/gamecube/Library/Android/sdk (DEPRECATED)
Running command: adb devices
Command finished with error code 0: adb devices
Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
CordovaError: Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
at /Users/gamecube/Desktop/geocars/platforms/android/cordova/lib/emulator.js:176:35
at processTicksAndRejections (internal/process/task_queues.js:97:5)
My questions
Why Android Emulator does not work?
and
Why is there this error? :
CordovaError: Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
Upvotes: 4
Views: 10485
Reputation: 16233
Without Android Studio, merely with Android Command Line Tools from Android SDK. Be sure these Android Command Line Tools (such as sdkmanager
or avdmanager
) are in the PATH, otherwise run them using the full path (for Debian/Ubuntu see this to install Android SDK).
Install the emulador
sdkmanager --install "emulator"
Install the platforms, example for Android API 32 and 33 (Android 12 and 13 respectively):
sdkmanager --install "system-images;android-32;google_apis;x86_64"
sdkmanager --install "system-images;android-33;google_apis;x86_64"
Create the Android Virtual Device (AVD), example:
avdmanager create avd -n emulator32 -k "system-images;android-32;google_apis;x86_64"
Confirm that was installed
avdmanager list avd
Run
cordova emulate android --target=emulator32
Upvotes: 6
Reputation: 336
I solved my problem.
How did I do it?
I then clicked on Apply (then OK on the pop-up) to download the package in question.
I added the path of avdmanager to PATH in my .bash_profile
I have run source ~ / .bash_profile
to refresh
And I launched my command: cordova emulate android --verbose
successfully since the emulator has opened well.
Upvotes: 5