首页 > 解决方案 > Android 崩溃:java.lang.RuntimeException:在 android.app.ActivityThread.performResumeActivity

问题描述

此错误发生在内部测试中(在开发中从未见过),并且到目前为止仅报告了一个用户,在一台设备上,其规格为:

它也是一个使用(一些可能相关的包)构建的 ReactNative 应用程序:

以下是 GooglePlay Console 上的日志:

java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3657)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3697)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1690)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:176)
  at android.app.ActivityThread.main (ActivityThread.java:6662)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)
Caused by: java.lang.NullPointerException: 
  at java.util.Objects.requireNonNull (Objects.java:203)
  at expo.modules.location.LocationModule.handleForegroundLocationPermissions (LocationModule.java:16)
  at expo.modules.location.LocationModule.lambda$requestForegroundPermissionsAsync$2 (LocationModule.java)
  at expo.modules.location.LocationModule.lambda$requestForegroundPermissionsAsync$2$LocationModule (LocationModule.java)
  at expo.modules.location.-$$Lambda$LocationModule$k4oVIWX5Tq-1bJGiv_G_lWYmJ10.onResult (-.java:4)
  at org.unimodules.adapters.react.permissions.PermissionsService$createListenerWithPendingPermissionsRequest$1.onRequestPermissionsResult (PermissionsService.java:32)
  at com.facebook.react.ReactActivityDelegate$2.invoke (ReactActivityDelegate.java:20)
  at com.facebook.react.ReactActivityDelegate.onResume (ReactActivityDelegate.java:12)
  at com.facebook.react.ReactActivity.onResume (ReactActivity.java:5)
  at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1355)
  at android.app.Activity.performResume (Activity.java:7182)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3632)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3697)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1690)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:176)
  at android.app.ActivityThread.main (ActivityThread.java:6662)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)

如果有帮助,下面还有应用程序的 MainActivity


    // Added automatically by Expo Config
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Intent intent = new Intent("onConfigurationChanged");
        intent.putExtra("newConfig", newConfig);
        sendBroadcast(intent);
    }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
    // SplashScreen.show(...) has to be called after super.onCreate(...)
    // Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
    SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
  }


    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "main";
    }

    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
            @Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }
        };
    }
}

任何帮助将不胜感激!

我也承认,任何使用 Crashlytics 之类的工具都会让生活变得更轻松,而且它们目前还没有集成。但是,如果这是唯一可以解决的方法,我也可以这样做,稍后……谢谢!

标签: javaandroidreact-nativeexpoexpo-permissions

解决方案


似乎没有授予位置权限

java.lang.NullPointerException: at java.util.Objects.requireNonNull (Objects.java:203) at expo.modules.location.LocationModule.handleForegroundLocationPermissions (LocationModule.java:16) at expo.modules.location.LocationModule.lambda$requestForegroundPermissionsAsync$2 (LocationModule.java) at expo.modules.location.LocationModule.lambda$requestForegroundPermissionsAsync$2$LocationModule (LocationModule.java)


推荐阅读