为android(离子项目)生成发布apk时
ionic cordova build android --release
- apk 使用 jarsigner 签名并使用 zipalign 压缩
如果安装了 mfp-plugin,它将不起作用。
该应用程序在两种情况下工作
- 安装了 mfp-plugin 并且 apk 处于调试模式
- 未安装 mfp-plugin 并且 apk 正在调试或发布
我需要的是让它在发布模式下工作并安装 mfp 插件。
打开应用程序后,它直接关闭,这是来自 logcat 的日志
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: a$f.uncaughtException in SourceFile:454 :: Uncaught Exception
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.addof.app/com.addof.app.MainActivity}: java.lang.RuntimeException: Failed to create webview.
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread.access$1100(ActivityThread.java:221)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.os.Handler.dispatchMessage(Handler.java:102)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.os.Looper.loop(Looper.java:158)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread.main(ActivityThread.java:7225)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.reflect.Method.invoke(Native Method)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: Caused by: java.lang.RuntimeException: Failed to create webview.
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at org.apache.cordova.CordovaWebViewImpl.createEngine(SourceFile:82)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at org.apache.cordova.CordovaActivity.makeWebViewEngine(SourceFile:206)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at org.apache.cordova.CordovaActivity.makeWebView(SourceFile:202)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at org.apache.cordova.CordovaActivity.init(SourceFile:146)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at com.addof.app.MainActivity.onCreate(SourceFile:27)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.Activity.performCreate(Activity.java:6876)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: ... 9 more
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: Caused by: java.lang.ClassNotFoundException: com.ionicframework.cordova.webview.IonicWebViewEngine
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.Class.classForName(Native Method)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.Class.forName(Class.java:324)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.Class.forName(Class.java:285)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at org.apache.cordova.CordovaWebViewImpl.createEngine(SourceFile:78)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: ... 16 more
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ionicframework.cordova.webview.IonicWebViewEngine" on path: DexPathList[[zip file "/data/app/com.addof.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.addof.app-1/lib/arm, /vendor/lib, /system/lib]]
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: ... 20 more
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: Suppressed: java.lang.ClassNotFoundException: com.ionicframework.cordova.webview.IonicWebViewEngine
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.Class.classForName(Native Method)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: ... 21 more
05-21 12:27:58.440 10869 10887 E com.worklight.common.a$f: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
05-21 12:27:58.445 10869 10869 E AndroidRuntime: FATAL EXCEPTION: main
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Process: com.addof.app, PID: 10869
05-21 12:27:58.445 10869 10869 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.addof.app/com.addof.app.MainActivity}: java.lang.RuntimeException: Failed to create webview.
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread.access$1100(ActivityThread.java:221)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.os.Looper.loop(Looper.java:158)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7225)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Caused by: java.lang.RuntimeException: Failed to create webview.
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at org.apache.cordova.CordovaWebViewImpl.createEngine(SourceFile:82)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at org.apache.cordova.CordovaActivity.makeWebViewEngine(SourceFile:206)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at org.apache.cordova.CordovaActivity.makeWebView(SourceFile:202)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at org.apache.cordova.CordovaActivity.init(SourceFile:146)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at com.addof.app.MainActivity.onCreate(SourceFile:27)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6876)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: ... 9 more
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: com.ionicframework.cordova.webview.IonicWebViewEngine
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.Class.forName(Class.java:324)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.Class.forName(Class.java:285)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at org.apache.cordova.CordovaWebViewImpl.createEngine(SourceFile:78)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: ... 16 more
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ionicframework.cordova.webview.IonicWebViewEngine" on path: DexPathList[[zip file "/data/app/com.addof.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.addof.app-1/lib/arm, /vendor/lib, /system/lib]]
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: ... 20 more
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: com.ionicframework.cordova.webview.IonicWebViewEngine
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
05-21 12:27:58.445 10869 10869 E AndroidRuntime: ... 21 more
05-21 12:27:58.445 10869 10869 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
05-21 12:27:58.450 4203 4644 D WindowAnimator: Skip setting animation background if there is an exiting window only.
05-21 12:27:58.455 4203 5462 W ActivityManager: Force finishing activity com.addof.app/.MainActivity
05-21 12:27:58.455 4203 5462 D FocusedStackFrame: Set to : 0
05-21 12:27:58.455 4203 5462 D InputDispatcher: Focused application set to: xxxx
05-21 12:27:58.495 4203 10889 E android.os.Debug: ro.product_ship = true
05-21 12:27:58.495 4203 10889 E android.os.Debug: ro.debug_level = 0x4f4c
05-21 12:27:58.495 4203 10889 E android.os.Debug: sys.mobilecare.preload = false
05-21 12:27:58.500 4203 4509 D ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{510da58 V.E...... R.....I. 0,0-0,0}
05-21 12:27:58.500 4203 4509 D ISSUE_DEBUG: InputChannelName : 6ce9496 Application Error: com.addof.app
05-21 12:27:58.505 4203 4509 V MARsPolicyManager: handelAlertToastWindowStarted pkgName = android
05-21 12:27:58.505 4203 4509 D InputDispatcher: Focus entered window: 4203
05-21 12:27:58.505 4203 4644 D PointerIcon: setMouseIconStyle1 pointerType: 1001 iconType:101 flag:0 pid:4203 uid:1000
05-21 12:27:58.505 4203 4644 D PointerIcon: setMouseCustomIcon IconType is same.101
05-21 12:27:58.505 4203 4644 D PointerIcon: setHoveringSpenIconStyle1 pointerType: 10001 iconType:1 flag:0 pid:4203 uid:1000
05-21 12:27:58.505 4203 4644 D PointerIcon: setHoveringSpenCustomIcon IconType is same.1
05-21 12:27:58.520 4203 4506 V BroadcastQueue: [background] Process cur broadcast BroadcastRecord{93f2817 u0 android.intent.action.DROPBOX_ENTRY_ADDED qIdx=4}, state= (APP_RECEIVE) DELIVERED for app ProcessRecord{d3f6cc5 13373:com.samsung.android.sm/1000}
05-21 12:27:58.535 3233 3233 I SurfaceFlinger: id=143 createSurf (193x193),1 flag=4, bpp
05-21 12:27:58.535 13373 13373 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1305 android.content.ContextWrapper.startService:606 android.content.ContextWrapper.startService:606 com.samsung.android.sm.common.SmartManagerReceiver.b:259 com.samsung.android.sm.common.SmartManagerReceiver.onReceive:107
05-21 12:27:58.555 4203 4974 D libEGL : eglInitialize EGLDisplay = 0x92f607c4
05-21 12:27:58.555 4203 4974 I OpenGLRenderer: Initialized EGL, version 1.4
05-21 12:27:58.560 4203 4974 D mali_winsys: new_window_surface returns 0x3000, [1528x918]-format:1
05-21 12:27:58.560 4203 4509 D StatusBarManagerService: manageDisableList userId=0 what=0x0 pkg=Window{6ce9496 u0 d0 Application Error: com.addof.app}
05-21 12:27:58.565 4203 6054 V BroadcastQueue: [background] Process cur broadcast BroadcastRecord{93f2817 u0 android.intent.action.DROPBOX_ENTRY_ADDED qIdx=4}, state= (APP_RECEIVE) DELIVERED for app ProcessRecord{ae9fefb 5892:com.google.android.gms/u0a17}
05-21 12:27:58.575 4203 4509 W DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-21 12:27:58.600 4203 7025 V BroadcastQueue: [background] Process cur broadcast BroadcastRecord{93f2817 u0 android.intent.action.DROPBOX_ENTRY_ADDED qIdx=4}, state= (APP_RECEIVE) DELIVERED for app ProcessRecord{1012bcb 6180:com.google.android.gms.persistent/u0a17}
05-21 12:27:58.600 4203 4215 I art : Background partial concurrent mark sweep GC freed 143195(9MB) AllocSpace objects, 96(3MB) LOS objects, 26% free, 43MB/59MB, paused 2.522ms total 123.111ms
05-21 12:27:58.610 3233 10338 I SurfaceFlinger: id=139 Removed Mauncher (3/10)
05-21 12:27:58.610 3233 3388 I SurfaceFlinger: id=139 Removed Mauncher (-2/10)
05-21 12:27:58.615 4203 4509 V WindowStateAnimator: Finishing drawing window Window{6ce9496 u0 d0 Application Error: com.addof.app}: mDrawState=DRAW_PENDING
05-21 12:27:58.615 3233 3233 D libEGL : eglTerminate EGLDisplay = 0xbed19464
05-21 12:27:58.615 3233 3233 D libEGL : eglInitialize EGLDisplay = 0xbed193fc
05-21 12:27:58.630 4203 4509 D ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
05-21 12:27:58.640 4203 4509 V WindowStateAnimator: Finishing drawing window Window{6ce9496 u0 d0 Application Error: com.addof.app}: mDrawState=HAS_DRAWN
05-21 12:27:58.640 4998 4998 D PhoneStatusBar: setSystemUiVisibility vis=8000 mask=ffffffff oldVal=8600 newVal=8000 diff=600
ioinc --info 的输出
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.4.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 23 other plugins)
System:
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v11.12.0 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
多功能一体机插件版本 8.0.2019050614
重现步骤
ionic start testApp blank
cd testApp
ionic cordova plugin add cordova-plugin-mfp
ionic cordova platform add android@latest
ionic cordova build android --release
cd platforms/android/app/build/outputs/apk/release
keytool -genkey -v -keystore app_key_sign.keystore -alias app_key_sign -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore app_key_sign.keystore app-release-unsigned.apk app_key_sign
~/Library/Android/sdk/build-tools/*/zipalign -v 4 app-release-unsigned.apk release.apk
adb install release.apk
- mac 设备上的 zipalign 路径