如何使用Cordova运行Android Emulator?

如何使用Cordova运行Android Emulator?,android,android-studio,cordova,sdk,phonegap,Android,Android Studio,Cordova,Sdk,Phonegap,先决条件 Android SDK安装良好(目录:/Users/gamecube/Library/Android/SDK) 如何复制: 运行此命令:cordova build android 运行此命令启动android emulator:cordova Simulate android--verbose 预期结果 Command finished with error code 0: /Users/gamecube/Desktop/geocars/platforms/android/grad

先决条件

  • Android SDK安装良好(目录:/Users/gamecube/Library/Android/SDK)
如何复制:

  • 运行此命令:
    cordova build android
  • 运行此命令启动android emulator:
    cordova Simulate android--verbose
  • 预期结果

    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)
    
    模拟器启动了

    获得的结果

    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模拟器不工作

    为什么会有这样的错误

    我解决了我的问题

    我是怎么做到的?

    • 我打开了Android Studio,并转到SDK管理器

    • 我点击了SDK工具选项卡,在显示的列表中,我选中了:Android SDK命令行工具(最新版本)

    • 然后,我点击Apply(然后在弹出窗口中点击OK)下载有问题的软件包

    • 我将avdmanager的路径添加到.bash_配置文件中的路径中

    • 我已运行
      source~/.bash\u profile
      进行刷新

    • 我启动了我的命令:
      cordova emulate android--verbose
      ,因为模拟器已经很好地打开了

      • 我解决了我的问题

        我是怎么做到的?

        • 我打开了Android Studio,并转到SDK管理器

        • 我点击了SDK工具选项卡,在显示的列表中,我选中了:Android SDK命令行工具(最新版本)

        • 然后,我点击Apply(然后在弹出窗口中点击OK)下载有问题的软件包

        • 我将avdmanager的路径添加到.bash_配置文件中的路径中

        • 我已运行
          source~/.bash\u profile
          进行刷新

        • 我启动了我的命令:
          cordova emulate android--verbose
          ,因为模拟器已经很好地打开了