react-native-orientation-locker
react-native-orientation-locker copied to clipboard
Samsung Android 9 crashes (`java.lang.NoSuchMethodError`)
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());
}
// ...
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.
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.