From aa27b7bb66700dcfc6191beaa978705685aedc9a Mon Sep 17 00:00:00 2001 From: Evan <59775655+evan1715@users.noreply.github.com> Date: Fri, 11 Nov 2022 04:08:15 -0500 Subject: [PATCH] chore: clarify installation instructions for Android (#1633) Giving more detail to where the override should be. ## Description Description and motivation for this PR. Helps users who are experiencing crashing from react-native-screens on Android who have placed the override in the wrong location. This modifies the readme for more clear instructions on what to do. When placed in the MainActivityDelegate, the crash still occurs, while placing it in the parent, it seems to be fine. Fixes #1481 . ## Test code and steps to reproduce N/A ## Checklist N/A Co-authored-by: Kacper Kafara --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ad27bad72..1cea7f01ad 100644 --- a/README.md +++ b/README.md @@ -51,13 +51,24 @@ On Android the View state is not persisted consistently across Activity restarts For most people using an app built from the react-native template, that means editing `MainActivity.java`, likely located in `android/app/src/main/java//MainActivity.java` You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes. +Please note that the override code should not be placed inside `MainActivityDelegate`, but rather directly in `MainActivity`. ```java import android.os.Bundle; -@Override -protected void onCreate(Bundle savedInstanceState) { - super.onCreate(null); +public class MainActivity extends ReactActivity { + + //...code + + //react-native-screens override + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(null); + } + + public static class MainActivityDelegate extends ReactActivityDelegate { + //...code + } } ```