Cordova android emulation - Error: Cannot read property 'semver' of null

前端 未结 6 834
醉梦人生
醉梦人生 2021-01-30 13:30

Trying to emulate Android app with cordova, but get this error message:

Built the following apk(s): /Users/jnj/cordova/hello/platforms/android/build/outputs/apk/andr

6条回答
  •  太阳男子
    2021-01-30 13:58

    I was getting this error because I thought the "emulation" command would start the emulator, but it seems to only use one that is already running. Some helpful commands and checks that are available on Windows 10 once you have Android Studio and cordova installed:

    1. cordova run --list will show no devices and give the semver error.
    2. adb devices -l should show no devices attached.
    3. Make sure your PATH environment variable includes %ANDROID_SDK_ROOT%\emulator, %ANDROID_SDK_ROOT%\platform-tools, %ANDROID_SDK_ROOT%\tools
    4. Emulator command line
      • Run emulator -list-avds to see which emulators are available. If none, then add them via Android Studio.
      • start cmd because you'll need another command line.
      • Start an emulator - Example: emulator -avd 7_WSVGA_Tablet_API_30 (note that underscores replace any spaces in the name)
    5. adb devices -l should now show a device like "emulator-5554"
    6. cordova run --list still gives a semver error. (Maybe this is a bug?)
    7. cordova run android (from your app's project directory) should start your app using the default emulator, or you can specify which one with cordova run android --target emulator-5554

提交回复
热议问题