wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Start white screen #3896

Closed knowledges closed 6 years ago

knowledges commented 6 years ago

Code Startup success,but android (Commd + M) invalid; I think it's a MainApplication.java problem, but I don't know where it is.

package com.selfrnapp;

import android.support.annotation.Nullable;

import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;

import java.util.List;

public class MainApplication extends NavigationApplication {
    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    @Nullable
    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        return null;
    }

    @Nullable
    @Override
    public String getJSMainModuleName() {
        return "index";
    }
}

package.json

{
  "name": "SelfRNApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.3",
    "react-native-navigation": "^1.1.484"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "4.0.0",
    "jest": "23.5.0",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  }
}
wx20180831-232736 2x
perrosnk commented 6 years ago

Could be related to this

Try the steps mentioned there, and probably switch off Remote debug and Hot reload

Anarcho-X commented 6 years ago

Make sure you do not use AppRegistry.registercomponent('appName', () => App);

Just import App from './src/App'; and then in App.js, register the components and then use

Navigation.events().registerAppLaunchedListener(() => {
        Navigation.setRoot(yourStackTree);
});
perrosnk commented 6 years ago

@spiraltrip Does this apply for the v.2 of RNN? Or is it applicable for the v.1 as well?

Anarcho-X commented 6 years ago

@perrosnk It applies to RNN2 because of registerAppLaunchedListener(). It needs to handle the native app launch event which must precede before React-Native's AppRegister.registerComponent() method. Well at least that's the experience and assumption I have.

knowledges commented 6 years ago

There is no solution yet.

knowledges commented 6 years ago

If react-native link react-native-navigation@latest can be executed directly, it will be perfect.

knowledges commented 6 years ago

This can block many problems.

knowledges commented 6 years ago

我已经降级到0.47.1 办吧了 I have been downgraded to 0.47.1. run success

Anarcho-X commented 6 years ago

I'm having problems with RN 0.56, as do many many people reporting. We can only wait for a bug fix 0.57. But, Im using 0.55.4 and RNN 2.0.2514 with no problems at all. Not necessary to downgrade to 0.47.1

You would really need to know how to configure libraries in Android project files - settings.gradle, build.gradle & app/build.gradle, MainActivity and MainApplication java files. If you learn a bit more and understand what these files do, you will get it and make things works. These configurations are needed from time to time for many other libraries too, like splash screens, vector-icons, firebase, etc.

Simply using and relying on react-native link will just mess up your config files with duplicates and unwanted insertions especially in the MainActivity and MainApplication java files.

The white screen problem could largely be due to problems in MainApplication file - as its the main file that creates a bridge between Android and React Native, and also loads any other javascript packages when the application starts. Also, since we are using React Native Navigation, we are extending the Application/Activity classes the provide. So check these files properly. You will solve the problem.

knowledges commented 6 years ago

I'm trying to try.