Android 集成中国银联支付 手机支付控件 Unable to start activity ComponentInfo
问题描述
安卓项目集成中国银联开放平台的手机支付控件(含安卓Pay),下载官方手机支付控件Demo https://open.unionpay.com/tjweb/acproduct/list?apiSvcId=450&index=5。Android Studio 打开 app开发包/控件开发包/upmp_android/demo/UPPayDemo
项目,并将 app开发包/控件开发包/upmp_android/sdkPro
文件夹里面的 jar 和 so 库放入 libs。运行成功后,点击 购买 ,app 奔溃闪退。
2020-03-18 16:01:53.135 8361-8361/com.unionpay.uppayplugin.demo E/PayDemo: 0
2020-03-18 16:01:53.176 8361-8361/com.unionpay.uppayplugin.demo E/BackgroundFallback: initVivoBgFallback callstackcom.android.internal.policy.DecorView.<init>:388 com.android.internal.policy.PhoneWindow.generateDecor:2441 com.android.internal.policy.PhoneWindow.installDecor:2820 com.android.internal.policy.PhoneWindow.setContentView:453 com.android.internal.app.AlertController.installContent:292 android.app.AlertDialog.onCreate:454 android.app.ProgressDialog.onCreate:272 android.app.Dialog.dispatchOnCreate:442 android.app.Dialog.show:337 android.app.ProgressDialog.show:190
2020-03-18 16:01:53.405 8361-8361/com.unionpay.uppayplugin.demo E/PayDemo: 763917069588988153020
2020-03-18 16:01:54.003 8361-8361/com.unionpay.uppayplugin.demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.unionpay.uppayplugin.demo, PID: 8361
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unionpay.uppayplugin.demo/com.unionpay.uppay.PayActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.io.InputStream.skip(long)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3254)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1997)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7056)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.io.InputStream.skip(long)' on a null object reference
at java.io.FilterInputStream.skip(FilterInputStream.java:151)
at com.unionpay.mobile.android.resource.c.a(Unknown Source:175)
at com.unionpay.mobile.android.widgets.m.<init>(Unknown Source:58)
at com.unionpay.mobile.android.widgets.m.<init>(Unknown Source:1)
at com.unionpay.mobile.android.plugin.BaseActivity.onCreate(Unknown Source:37)
at com.unionpay.uppay.PayActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:7255)
at android.app.Activity.performCreate(Activity.java:7246)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3099)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3254)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1997)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7056)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
解决方案
在官方 Demo 的文件夹中,将 app开发包/控件开发包/upmp_android/sdkPro/jar/data.bin
文件,拷贝到 app/src/main/assets/data.bin
,目录结构如下图:
重新编译运行,点击 购买 成功跳转到支付环节。
非特殊说明,本网站所有文章均为原创。如若转载,请注明出处:https://mip.cpming.top/p/android-unionpay-unable-to-start-activity