[英]How do I debug when using ionic emulate android
I created an application using ionic: 我使用ionic创建了一个应用程序:
ionic start MyFirstApp blank
cd MyFirstApp
ionic serve
ionic platform add android
ionic build android
ionic emulate android
Everything is successful except the emulator step. 除了模拟器步骤外,一切都很成功。 The emulator boots up, but I get "Unfortunately, MyFirstApp has stopped".
模拟器启动,但我得到“不幸的是,MyFirstApp已停止”。 Everything brand new straight out of the box, no changes to code.
一切都是全新的直接开箱即用,代码没有变化。
What next? 接下来是什么? How do I debug what has gone wrong?
我如何调试出错的地方?
EDIT This is the output displayed when I call ionic build android
: 编辑这是我调用
ionic build android
时显示的输出:
C:\Users\Colin\Documents\Ionic\MyFirstApp>ionic build android
add to body class: platform-android
Running command: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\cordova\build.bat
Buildfile: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at C:\Program Files\Eclipse\adt-bundle-windows-x86_64-20140702\sdk
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
nodeps:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at C:\Program Files\Eclipse\adt-bundle-windows-x86_64-20140702\sdk
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Android Library
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found new input file
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
-compile:
[echo] Creating library output jar file...
-post-compile:
-obfuscate:
-dex:
[echo] Library project: do not convert bytecode...
-crunch:
[crunch] Crunching PNG Files in source dir: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\res
[crunch] To destination dir: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\res
[crunch] Crunched 0 PNG files to update cache
-package-resources:
[echo] Library project: do not package resources...
-package:
[echo] Library project: do not package apk...
-post-package:
-do-debug:
[echo] Library project: do not create apk...
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\build.prop
-post-build:
debug:
-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found Deleted Target File
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
[echo] Set jars path to: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\classes.jar
-compile:
[javac] Compiling 2 source files to C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\classes
-post-compile:
-obfuscate:
-dex:
[dex] input: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\classes
[dex] input: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\classes.jar
[dex] Using Pre-Dexed classes-3a52ec06bbf9dc987d551c9695e3393a.jar <- C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build\classes.jar
[dex] Found Deleted Target File
[dex] Converting compiled files and external libraries into C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\classes.dex...
[dx] Merged dex A (12 defs/8.7KiB) with dex B (209 defs/317.1KiB). Result is 221 defs/396.2KiB. Took 0.2s
-crunch:
[crunch] Crunching PNG Files in source dir: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\res
[crunch] To destination dir: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\res
[crunch] Crunched 0 PNG files to update cache
-package-resources:
[aapt] Found Deleted Target File
[aapt] Creating full resource package...
-package:
[apkbuilder] Found Deleted Target File
[apkbuilder] Creating MyFirstApp-debug-unaligned.apk and signing it with a debug key...
-post-package:
-do-debug:
[zipalign] Running zip align on final apk...
[echo] Debug Package: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\MyFirstApp-debug.apk
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\build.prop
-post-build:
[move] Moving 1 file to C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build
[move] Moving 1 file to C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\CordovaLib\ant-build
debug:
BUILD SUCCESSFUL
Total time: 4 seconds
Using apk: C:\Users\Colin\Documents\Ionic\MyFirstApp\platforms\android\ant-build\MyFirstApp-debug-unaligned.apk
EDIT 2 This is the output from android list avd
编辑2这是
android list avd
的输出
Available Android Virtual Devices:
Name: Nexus7
Device: Nexus 7 (Google)
Path: C:\Users\Colin\.android\avd\Nexus7.avd
Target: Android 4.4W (API level 20)
Tag/ABI: android-wear/armeabi-v7a
Skin: WVGA800
A much easier/better solution in my opinion is to use the chrome://inspect tool on chrome. 在我看来,更简单/更好的解决方案是在chrome上使用chrome:// inspect工具。
Launch the app on your Android using 使用Android在Android上启动应用
ionic run android 离子运行android
Open Chrome and go to: chrome://inspect - this will list your connected devices. 打开Chrome并转到:chrome:// inspect - 这将列出您连接的设备。
Inspect the app using chrome dev tools as if you were inspecting any other web page. 使用chrome dev工具检查应用程序,就像检查任何其他网页一样。
Please make sure you created the right avd configuration for the emulator. 请确保为模拟器创建了正确的avd配置。
type android list avd
and see the output. 键入
android list avd
并查看输出。 What is the first avd listed there ? 什么是第一个在那里列出的avd? If it shows older API level (for eg: 7)
如果它显示较旧的API级别(例如:7)
API level 9 and higher is required, API level 15 and high preferred. API 级别9及更高级别是必需的,API级别15和高级首选。 You cannot use API 20 Android Wear AVD, as it is only for testing wear devices.
您不能使用API 20 Android Wear AVD,因为它仅用于测试磨损设备。
You can delete the existing avd with android delete avd -n Name
(replace Name
with yours). 你可以用
android delete avd -n Name
删除现有的avd(用你的android delete avd -n Name
替换你的Name
)。
create one with android create avd --name test15 --target android-15 --abi x86
用
android create avd --name test15 --target android-15 --abi x86
创建一个android create avd --name test15 --target android-15 --abi x86
make sure android list avd
shows your avd is the first listed. 确保
android list avd
显示你的avd是第一个列出的。
I followed the same steps, i use windows, my ionic build android
output is similar to yours; 我按照相同的步骤,我使用Windows,我的
ionic build android
输出类似于你的; I was able to get ionic emulate android
working with API-15, please see below: 我能够使用API-15进行
ionic emulate android
,请看下面:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.