如下是一些ionic app在模擬器中的調試問題:javascript
1. CORS問題java
官方原文以及解釋:Handling CORS issues in Ionicandroid
2. SplashScreen以後顯示問題git
如圖,默認的側邊滾動條也在,頁首位置也在,佈局都在,就是內容顯示異常,只顯示黑塊和白塊。github
這個是在添加crosswalk以後出現的,crosswalk支持的android api是16以上;api
我使用的是genymotion,運行:ionic cordova run android,在Chrome中console沒有報錯;跨域
運行ionic cordova run android -l -c 就會出現CORS問題,原理見1;app
運行ionic cordova run android --device --prod,出現提示:cors
[WARN] Error occurred during command execution from a CLI plugin
(@ionic/cli-plugin-cordova). Your plugins may be out of date.
Error: Type AboutPage in /src/pages/about/about.ts is part of the declarations of 2 modules: AppModule in /src/app/app.module.ts and AboutPageModule in /src/pages/about/about.module.ts!
Please consider moving AboutPage in /src/pages/about/about.ts to a higher module that imports AppModule in /src/app/app.module.ts and AboutPageModule in/src/pages/about/about.module.ts.
You can also create a new NgModule that exports and includes AboutPage in /src/pages/about/about.ts then import that NgModule in AppModule in /src/app/app.module.ts and AboutPageModule in /src/pages/about/about.module.ts.composer
這個報錯好解決,在app.module.ts中
import { AboutPageModule } from '../pages/about/about.module';
而後imports中加入 AboutPageModule。
可是運行命令的話仍是黑白塊。
打包Genymotion emulator的log觀察發現報錯了,基本上是emulator啓動過程當中就報錯了,報錯的關鍵部分:
06-22 04:14:44.461 I/AudioFlinger( 240): Using default 3000 mSec as standby time.
06-22 04:14:44.462 E/ ( 240): batterystats service unavailable!
06-22 04:14:44.462 E/ ( 240): batterystats service unavailable!
06-22 04:14:44.465 I/CameraService( 240): CameraService started (pid=240)
06-22 04:14:44.465 I/CameraService( 240): CameraService process starting
06-22 04:14:44.465 E/ ( 240): batterystats service unavailable!
06-22 04:14:44.465 E/ ( 240): batterystats service unavailable!
06-22 04:14:44.513 W/gatekeeperd( 133): falling back to software GateKeeper
06-22 04:14:44.744 I/SurfaceFlinger( 229): SurfaceFlinger is starting
06-22 04:14:44.744 I/SurfaceFlinger( 229): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
06-22 04:14:44.868 I/Genymotion( 225): overriding Battery service paths with fake ones
06-22 04:14:44.925 D/libEGL ( 229): loaded /system/lib/egl/libEGL_emulation.so
06-22 04:14:44.926 D/libEGL ( 229): loaded /system/lib/egl/libGLESv1_CM_emulation.so
06-22 04:14:44.930 D/libEGL ( 229): loaded /system/lib/egl/libGLESv2_emulation.so
06-22 04:14:44.933 E/ ( 229): Failed to connect to host (UnixStream)!!!
06-22 04:14:44.933 E/EGL_emulation( 229): Failed to establish connection with the host
06-22 04:14:44.933 W/libEGL ( 229): eglInitialize(0xf6bbf080) failed (EGL_SUCCESS)
06-22 04:14:44.965 E/ ( 229): Failed to connect to host (UnixStream)!!!
06-22 04:14:44.965 E/gralloc_vbox86( 229): gralloc: Failed to get host connection
06-22 04:14:44.965 E/SurfaceFlinger( 229): hwcomposer module not found
06-22 04:14:44.965 E/SurfaceFlinger( 229): ERROR: failed to open framebuffer (I/O error), aborting
--------- beginning of crash
06-22 04:14:44.965 F/libc ( 229): Fatal signal 6 (SIGABRT), code -6 in tid 229 (surfaceflinger)
06-22 04:14:45.004 I/iptables( 236): iptables v1.4.20: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
06-22 04:14:45.004 I/iptables( 236): Perhaps iptables or your kernel needs to be upgraded.
06-22 04:14:45.004 I/iptables( 236): iptables terminated by exit(3)
06-22 04:14:45.004 E/Netd ( 236): exec() res=0, status=768 for /system/bin/iptables -w -t nat -N oem_nat_pre
06-22 04:14:45.007 I/iptables( 236): iptables v1.4.20: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
06-22 04:14:45.007 I/iptables( 236): Perhaps iptables or your kernel needs to be upgraded.
06-22 04:14:45.007 I/iptables( 236): iptables terminated by exit(3)
06-22 04:14:45.007 E/Netd ( 236): exec() res=0, status=768 for /system/bin/iptables -w -t nat -A PREROUTING -j oem_nat_pre
06-22 04:14:45.019 I/iptables( 236): iptables v1.4.20: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
06-22 04:14:45.019 I/iptables( 236): Perhaps iptables or your kernel needs to be upgraded.
06-22 04:14:45.020 I/iptables( 236): iptables terminated by exit(3)
06-22 04:14:45.020 E/Netd ( 236): exec() res=0, status=768 for /system/bin/iptables -w -t nat -N natctrl_nat_POSTROUTING
06-22 04:14:45.024 I/iptables( 236): iptables v1.4.20: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
06-22 04:14:45.024 I/iptables( 236): Perhaps iptables or your kernel needs to be upgraded.
06-22 04:14:45.024 I/iptables( 236): iptables terminated by exit(3)
06-22 04:14:45.024 E/Netd ( 236): exec() res=0, status=768 for /system/bin/iptables -w -t nat -A POSTROUTING -j natctrl_nat_POSTROUTING
06-22 04:14:45.072 F/DEBUG ( 237): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-22 04:14:45.072 F/DEBUG ( 237): Build fingerprint: 'Android/vbox86p/vbox86p:6.0/MRA58K/genymotion03201937:userdebug/test-keys'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageArmv7Release'.
> com.android.ide.common.signing.KeytoolException: Failed to read key
gitbookexplorer from store
"D:\Workspace\gitbookexplorer\platforms\android\gitbookexplorer.keystore
":
Keystore was tampered with, or password was incorrect* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
BUILD FAILED
Total time: 2.429 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.* What went wrong:
Execution failed for task ':packageArmv7Release'.
> com.android.ide.common.signing.KeytoolException: Failed to read key
from store
"\platforms\android\gitbookexplorer.keystore
":
Keystore was tampered with, or password was incorrect* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
沒有提示輸入密碼,搜索錯誤:
or reference, I needed to update the release-signing.properties to:
storeFile=../../key.keystore
keyAlias=mykey
keyPassword=password
storePassword=passwordThese override the setting in build.gradle:signingConfigs {release {// These must be set or Gradle will complain (even if they are overridden).keyAlias = ""keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.storeFile = nullstorePassword = "__unset"}}