react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

Samsung Android 9 crashes (`java.lang.NoSuchMethodError`)

Open AdamTimberlake-Which opened this issue 4 years ago • 2 comments

Noticed a lot of errors for mostly Samsung users on Android 9 from Crashlytics:

Fatal Exception: java.lang.NoSuchMethodError
No virtual method registerActivityLifecycleCallbacks(Landroid/app/Application$ActivityLifecycleCallbacks;)V in class Luk/co/which/reviews/MainActivity; or its super classes (declaration of 'uk.co.which.reviews.MainActivity' appears in base.apk!classes2.dex)
public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
  }

 // ...

AdamTimberlake-Which avatar Nov 12 '21 11:11 AdamTimberlake-Which

Don't know if this is related, but I've encountered this as well. I've added the registerActivityLifecycleCallbacks to MainActivity.java as well, but it should be part of the MainApplication.java. That fixed it for me. Strangely, this only happens on Samsung phones.

benediktpascher avatar Aug 16 '22 08:08 benediktpascher

That method only exists on the Activity on API 29+ while it exists on Application from API 16+. That's the cause of the NoSuchMethodError.

radixdev avatar Jan 10 '23 22:01 radixdev