先决条件
如何复制:
cordova build android
cordova模拟android--详细
预期结果
模拟器启动。
获得结果
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)
我的问题
为什么Android模拟器不起作用?
和
为什么会有这个错误?:
CordovaError: Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
我解决了我的问题。
我是怎么做到的?
>
然后我点击应用(然后在弹出窗口上确定)下载有问题的包。
我在我的.bash_profile中添加了avdmanager到PATH的路径
我已经运行source~/.bash_profile
刷新
我启动了我的命令:cordova模拟android--详细
成功,因为模拟器打开得很好。
如果没有Android Studio,只需使用AndroidSDK的Android命令行工具。请确保这些Android命令行工具(例如sdkmanager
或avdmanager
)位于PATH中,否则使用完整路径运行它们(对于Debian/Ubuntu,请参阅此以安装AndroidSDK)。
安装模拟器
sdkmanager --install "emulator"
安装平台,例如AndroidAPI32和33(分别为Android 12和13):
sdkmanager --install "system-images;android-32;google_apis;x86_64"
sdkmanager --install "system-images;android-33;google_apis;x86_64"
创建Android虚拟设备(AVD),例如:
avdmanager create avd -n emulator32 -k "system-images;android-32;google_apis;x86_64"
确认已安装
avdmanager list avd
快跑
cordova emulate android --target=emulator32