I am trying to run hello world cordova project. I am able to run this project in mobile phone but while I am trying to run using android studio emulator, it throw error:
BUILD SUCCESSFUL in 2s
47 actionable tasks: 1 executed, 46 up-to-date
Built the following apk(s):
C:\Users\vinay\AndroidStudioProjects\Cordova\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk
ANDROID_HOME=C:\Users\vinay\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161
No target specified, deploying to device '4172aa4d'.
none
Skipping build...
Built the following apk(s):
C:\Users\vinay\AndroidStudioProjects\Cordova\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Using apk: C:\Users\vinay\AndroidStudioProjects\Cordova\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Package name: com.example.hello
LAUNCH SUCCESS
Android studio version- 3.0.1 , cordova version 8.0.0, Cordova requirements
C:\Users\vinay\AndroidStudioProjects\Cordova\hello>cordova requirements
Android Studio project detected
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26,android-25,android-24,Google Inc.:Google APIs:24,android-23,Google Inc.:Google APIs:23
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle
Please help me to find out what I am missing.
EDIT Updated after Christian Wico response:
I tried to run
cordova run android --emulator
Now it throw another error
BUILD SUCCESSFUL in 2s
47 actionable tasks: 1 executed, 46 up-to-date
Built the following apk(s):
C:\Users\vinay\AndroidStudioProjects\Cordova\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk
ANDROID_HOME=C:\Users\vinay\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161
(node:10860) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: No emulator images (avds) found.
1. Download desired System Image by running: "C:\Users\vinay\AppData\Local\Android\Sdk\tools\android.bat" sdk
2. Create an AVD by running: "C:\Users\vinay\AppData\Local\Android\Sdk\tools\android.bat" avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
(node:10860) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Your first code group is a SUCCESS message. The other one is just environment info. Where is the error message?
Unless there is an absolute need to deploy your project using Android Studio, you should use the Cordova CLI to launch your apps .
To launch, you administer the following command from within your project directory:
cordova run android
The command will preferably launch the app from within an attached device. Should you wish to explicitly tell the CLI to launch into an emulator, use the --emulator
flag along with your run
command:
cordova run android --emulator
解决此问题的一种方法是重新启动模拟器。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.