matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
226 stars 43 forks source link

getting exception "android.util.SuperNotCalledException" on play store pre launch #78

Open kendo-leadlab opened 7 months ago

kendo-leadlab commented 7 months ago

after migrating to 2.0.1 i am starting to get on the pre-lunch report a single crash, although this is working for most of my users some of them complained on repeating crash's

android.util.SuperNotCalledException: Activity {com.xxx/com.xxx.MainActivity} did not call through to super.onCreate()
Exception android.util.SuperNotCalledException: Activity {com.protein2/com.protein2.MainActivity} did not call through to super.onCreate()
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3692)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3864)
  at android.app.ActivityThread.handleRelaunchActivityInner (ActivityThread.java:5811)
  at android.app.ActivityThread.handleRelaunchActivity (ActivityThread.java:5703)

To Reproduce i didn't managed to reproduce on my devices or emulator but i noticed that when i am changing super.onCreate(null) from super.onCreate(savedInstanceState) the error is not happening

Environment on play store :

** MainActivity.kt

package com.xxxxx

import android.os.Bundle
import android.os.Build

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import dev.matinzd.healthconnect.permissions.HealthConnectPermissionDelegate
import expo.modules.ReactActivityDelegateWrapper

class MainActivity : ReactActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    try {
      setTheme(R.style.AppTheme);
      super.onCreate(savedInstanceState)
      HealthConnectPermissionDelegate.setPermissionDelegate(this)
    } catch (e: Exception) {

    }      
  }

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  override fun getMainComponentName(): String = "main"

  /**
   * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
   * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
   */
  override fun createReactActivityDelegate(): ReactActivityDelegate {
    return ReactActivityDelegateWrapper(
          this,
          BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
          object : DefaultReactActivityDelegate(
              this,
              mainComponentName,
              fabricEnabled
          ){})
  }

  /**
    * Align the back button behavior with Android S
    * where moving root activities to background instead of finishing activities.
    * @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
    */
  override fun invokeDefaultOnBackPressed() {
      if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
          if (!moveTaskToBack(false)) {
              // For non-root activities, use the default implementation to finish them.
              super.invokeDefaultOnBackPressed()
          }
          return
      }

      // Use the default back button implementation on Android S
      // because it's doing more than [Activity.moveTaskToBack] in fact.
      super.invokeDefaultOnBackPressed()
  }
}
matinzd commented 6 months ago

Hello!

Can you please provide a reproducible?