Android 11下银行APP启动即空指针崩溃问题排查
移动端银行应用线上启动崩溃排查资料
问题基本情况
- 自研移动端银行应用通过Google Play商店完成分发后,用户下载打开应用时会在启动页直接崩溃,初期无法定位崩溃对应的具体代码行号
- 崩溃直接触发点为系统层面
PhoneWindow.getInsetsController方法抛出空指针,调用链最终指向启动页SS的onCreate方法 - 现有测试验证结果:一加品牌设备上应用运行正常;因缺少搭载Android 11系统的测试设备,无法通过本地复现的方式定位并解决问题
线上采集的崩溃堆栈
从Google Play Console拉取到的完整崩溃日志如下:
java.lang.RuntimeException: at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3779) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3943) at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2276) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:246) at android.app.ActivityThread.main (ActivityThread.java:8414) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:596) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130) Caused by: java.lang.NullPointerException: at com.android.internal.policy.PhoneWindow.getInsetsController (PhoneWindow.java:4120) at com.mbanking.vsbl.vsbl.activity.SS.onCreate (Unknown Source:14) at android.app.Activity.performCreate (Activity.java:8171) at android.app.Activity.performCreate (Activity.java:8155) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3752)
崩溃关联的启动页实现代码
崩溃触发路径涉及的启动页Activity(类名SS)完整实现代码如下:
package com.mbanking.vsbl.vsbl.activity; @SuppressWarnings({"unused", "deprecation"}) public class SS extends Activity { //变量声明 private Context ctx; private static AlertDialog alertDialog; private Utils utils; // public native String abc(); private final WSCallerVersionListener wSCallerVersionListener = new WSCallerVersionListener() { @Override public void onGetResponse(boolean isUpdateAvailable) { if (isUpdateAvailable) { showUpdateDialog(); } else { submit_getBankDetails_MOB(); } } }; @Override protected void onCreate(Bundle savedInstanceState) { //通过代码移除状态栏 requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_splashscreen); ctx = this; utils = new Utils(); HeaderImageUtils headerImageUtils = new HeaderImageUtils(); ImageView splashlogo = findViewById(R.id.splashlogo); ImageView csplashlogo = findViewById(R.id.csplashlogo); TextView text_bankname = findViewById(R.id.text_bankname); headerImageUtils.setImage(Constants.BANK_ID, splashlogo, ctx, csplashlogo); //参考常量配置对应应用名称 Prefs.setAndroid_id(ctx, Constants.app_ajmsb); text_bankname.setText(Constants.bankname_cedge); //清空所有缓存值 Prefs.setpausetime(ctx, null); InternetConnectionUtils internetConnectionUtils = new InternetConnectionUtils(); int Internet_check = internetConnectionUtils.Internetconnect_Check(ctx); if (Internet_check == 0) { int appsignautestatus = Utils.checkAppSignatureALL(ctx); if (appsignautestatus == 0) { if (!Utils.isDeviceRooted()) { new GPSA(ctx, wSCallerVersionListener).execute(); } else { CommonDialog.DeleteAlertRoot(ctx,utils); } } else { CommonDialog.DeleteAlert(ctx, utils); } } else { CommonDialog.simpleAlert(alertDialogInterface, utils, "#275599", ctx, getString(R.string.netconnect), Constants.INTERNET); } } private void submit_getBankDetails_MOB() { CommonDialog.progressAlert(ctx); MobileUserDTO mobileUserDTO = new MobileUserDTO(); APIRestCallTask asyncTask = new APIRestCallTask(ctx, mResultCallback, ServerUtils.getBankDetails_MOB, "getBankDetails_MOB", mobileUserDTO); asyncTask.execute(); } @Override protected void onDestroy() { CommonDialog.ondismiss(); CommonDialog.onProgressdismiss(); super.onDestroy(); } //通过接口回调接收弹窗操作状态,返回上一页面 private final AlertDialogInterface alertDialogInterface = new AlertDialogInterface() { @Override public void DialogRestult(String result) { finish(); finishAffinity(); } }; private void Restcall1(String str_Theme_color) { if (str_Theme_color.equalsIgnoreCase("themeRed")) { Prefs.setapptoolbackdark(ctx, "#D32F2F"); Prefs.setappbacklight(ctx, "#F34E46"); Prefs.setGradient_middle(ctx, "#FF6B5E"); } else { Prefs.setapptoolbackdark(ctx, "#275599"); Prefs.setappbacklight(ctx, "#476DB4"); Prefs.setGradient_middle(ctx, "#6486D0"); } } //通过异步任务获取RestTemplate返回的响应结果 private final IResult mResultCallback = new IResult() { @Override public void notifySuccess(String response, String str_fromapi) { CommonDialog.onProgressdismiss(); String[] result = response.split(" ", 2); String response1; if (response.length() > 0) { if (response.length() == 5) { response1 = response.substring(0, 5); } else { response1 = response.substring(0, 7); } } else { response1 = response; } if (response1.toLowerCase().contains(Constants.SUCCESS.toLowerCase())) { CommonDialog.simpleAlert(alertDialogInterface, utils, "#275599", ctx, response, Constants.SUCCESS); } else if (response1.toLowerCase().contains(Constants.ALERT.toLowerCase())) { CommonDialog.simpleAlert(alertDialogInterface, utils, "#275599", ctx, result[1].replace(":", ""), Constants.ALERT); } else if (response1.toLowerCase().contains(Constants.ERROR.toLowerCase())) { CommonDialog.simpleAlert(alertDialogInterface, utils, "#275599", ctx, response, Constants.ERROR); } else { try { JSONObject jsonObject = new JSONObject(response); JSONObject jsonObject1 = jsonObject.getJSONObject("bankURLs"); String str_theme = jsonObject1.getString("theme"); Restcall1(str_theme); Base64Encoder_Decoder base64Encoder_decoder = new Base64Encoder_Decoder(); String str_encodedparams = base64Encoder_decoder.encrypt(response, base64Encoder_decoder.decrypt_sig(Prefs.getAndroid_id(ctx), Utils.Get_Sha_lt(Utils.checkAppSignature(ctx)))); SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences.Editor prefsEditor = appSharedPrefs.edit(); prefsEditor.putString("bankresponse", str_encodedparams); prefsEditor.apply(); Prefs.setbankresponse(ctx,str_encodedparams); Intent nextPage = new Intent(SS.this, SSS.class); nextPage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(nextPage); finish(); finishAffinity(); } catch (Exception ignored) { } } } @Override public void notifyError(String error) { CommonDialog.onProgressdismiss(); CommonDialog.simpleAlert(alertDialogInterface, utils, "#275599", ctx, error, Constants.ERROR); } }; private void showUpdateDialog() { final String appUrl = Utils.fetchApplicationUrl(ctx); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(SS.this); alertDialogBuilder.setTitle(SS.this.getString(R.string.app_name)); alertDialogBuilder.setMessage(SS.this.getString(R.string.updateapp)); alertDialogBuilder.setCancelable(false); alertDialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (alertDialog != null && alertDialog.isShowing()) { alertDialog.dismiss(); alertDialog.cancel(); SS.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appUrl))); } } }); if (!((Activity) ctx).isFinishing()) { alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } }
内容的提问来源于stack exchange,提问作者pooja
相关产品推荐
相关产品推荐

