0

我有一个 android 应用程序,当主要活动在模块中启动一个活动时,该应用程序中包含第二个模块,一切都很好。问题是,如果您转到另一个应用程序然后恢复此应用程序,则活动会因空对象指针而崩溃。我的应用程序使用 Esri ArcGIS 运行时 SDK。发生崩溃时,我在活动中打开了一个 MapView。我对 MainActivity 中的打开地图没有任何问题,应用程序进入后台,然后返回当前应用程序。

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thevillages.myfirstapp, PID: 23267
    java.lang.RuntimeException: Unable to resume activity {com.thevillages.myfirstapp/com.thevillages.maplib.MapNavActivity}: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4205)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
   at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
   at android.os.Handler.dispatchMessage(Handler.java:107)
   at android.os.Looper.loop(Looper.java:214)
   at android.app.ActivityThread.main(ActivityThread.java:7356)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
   at com.esri.arcgisruntime.internal.jni.CoreGeoView.nativeResume(Native Method)
   at com.esri.arcgisruntime.internal.jni.CoreGeoView.b(SourceFile:5)
   at com.esri.arcgisruntime.a.i.f.g.d(SourceFile:3)
   at com.esri.arcgisruntime.mapping.view.GeoView$RenderingThread.resume(SourceFile:4)
   at com.esri.arcgisruntime.mapping.view.MapView.resume(SourceFile:1)
   at com.thevillages.maplib.MapNavActivity.onResume(MapNavActivity.java:816)
   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
   at android.app.Activity.performResume(Activity.java:7939)
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237) 
   at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
   at android.os.Handler.dispatchMessage(Handler.java:107) 
   at android.os.Looper.loop(Looper.java:214) 
   at android.app.ActivityThread.main(ActivityThread.java:7356) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
4

1 回答 1

1

我系统地检查了我的 onCreate() 方法并添加了每一段代码以找出问题所在。我发现了一些可疑的代码,我不记得为什么要添加代码。删除代码后,应用程序可以正常工作。

于 2021-05-11T14:30:24.867 回答