所以我尝试将android模拟器用于我的离子应用程序,因为我需要尝试使用他们的Web服务器方法无法实现的sqlite。
反正。我做了什么:
cd myProject
离子cordova build android =>成功
离子cardova模拟android
BUILD SUCCESSFUL in 1s
47 actionable tasks: 1 executed, 46 up-to-date
Built the following apk(s):
/home/foo/testApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk
[17:34:24] lint finished in 3.58 s
(node:1425) UnhandledPromiseRejectionWarning: CordovaError: No emulator images (avds) found.
1. Download desired System Image by running: /opt/android-sdk/tools/android sdk
2. Create an AVD by running: /opt/android-sdk/tools/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
at /home/foo/testApp/platforms/android/cordova/lib/emulator.js:288:29
at _fulfilled (/home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:816:13)
at /home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:624:44
at runSingle (/home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/foo/testApp/platforms/android/cordova/node_modules/q/q.js:125:13)
at process._tickCallback (internal/process/next_tick.js:150:11)
(node:1425) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1425) [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.
此外:
$ avdmanager list avd
Parsing /opt/android-sdk/build-tools/27.0.3/package.xmlParsing /opt/android-sdk/extras/android/m2repository/package.xmlParsing /opt/android-sdk/extras/google/m2repository/package.xmlParsing /opt/android-sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/package.xmlParsing /opt/android-sdk/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/package.xmlParsing /opt/android-sdk/patcher/v4/package.xmlParsing /opt/android-sdk/platform-tools/package.xmlParsing /opt/android-sdk/platforms/android-26/package.xmlParsing /opt/android-sdk/platforms/android-27/package.xmlParsing /opt/android-sdk/sources/android-27/package.xmlParsing /opt/android-sdk/system-images/android-23/google_apis/x86/package.xmlParsing /opt/android-sdk/system-images/android-25/google_apis/x86/package.xmlParsing /opt/android-sdk/tools/package.xmlAvailable Android Virtual Devices:
Name: test
Device: Nexus 4 (Google)
Path: /home/foo/.android/avd/test.avd
Target: Google APIs (Google Inc.)
Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86
Sdcard: 100M
---------
Name: test123
Path: /home/foo/.android/avd/test123.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
---------
Name: test2
Path: /home/foo/.android/avd/test2.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
---------
Name: test3
Path: /home/foo/.android/avd/test3.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
---------
Name: thename
Path: /home/foo/.android/avd/thename.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
---------
Name: thename2
Path: /home/foo/.android/avd/thename2.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
所以我确实有avds - 没有?
问题是什么?
答案 0 :(得分:1)
我认为你的路径不匹配。尝试明确指定avd
答案 1 :(得分:0)
我用以下方法解决了同样的错误:
ionic cordova platform rm android
ionic cordova platform add android@7.1.0
并运行Android模拟器(来自终端或Android Studio),然后使用离子cordova模拟android