react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Blank white screen on Android, IOS working fine!

Open mohdabbas opened this issue 8 years ago • 93 comments

Issue Description

I get a blank white screen on react-native run-android, can't even access CMD+M for dev menu. IOS working perfectly fine. If I run http://localhost:8081/index.android.bundle?platform=android&dev=false&hot=false&minify=false in browser, it says: "message": "Cannot find entry file index.android.js in any of the roots: ["/Projects/Mobile Applications/Project"]", even I have added @Override public String getJSMainModuleName() { return "index"; } in MainApplication.java,

(https://github.com/wix/react-native-navigation/issues/197)]

Steps to Reproduce / Code Snippets / Screenshots

App.js

import { Navigation } from 'react-native-navigation';

import { registerScreens } from './src/screens';

registerScreens(); // this is where you register all of your app's screens

// start the app
Navigation.startTabBasedApp({
  tabs: [
    {
      label: 'One',
      screen: 'Project.SplashScreen', // this is a registered name for a screen
      title: 'Screen One'
    }
  ]
});

screens/index.js

import { Navigation } from 'react-native-navigation';

import SplashScreen from './splash/splash.screen';

// register all screens of the app (including internal ones)
export function registerScreens() {
  Navigation.registerComponent('Project.SplashScreen', () => SplashScreen);
}

MainActivity.java

package com.bricofer;

import com.reactnativenavigation.controllers.SplashActivity;

public class MainActivity extends SplashActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    protected String getMainComponentName() {
        return "Project";
    }
}

MainApplication.java

package com.project;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;
import com.reactnativenavigation.NavigationApplication;

public class MainApplication extends NavigationApplication {

     @Override
     public boolean isDebug() {
         // Make sure you are using BuildConfig from your own application
         return BuildConfig.DEBUG;
     }

     protected List<ReactPackage> getPackages() {
         // Add additional packages you require here
         // No need to add RnnPackage and MainReactPackage
         return Arrays.<ReactPackage>asList(
             // eg. new VectorIconsPackage()
         );
     }

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

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

Kindly help!!!

Thanks


Environment

  • React Native Navigation version: 1.1.375
  • React Native version: 0.52.0
  • Platform(s) (iOS, Android, or both?): Android

mohdabbas avatar Feb 09 '18 12:02 mohdabbas

Even, If I change the files to index.ios.js and index.android.js, same problem in Android. I am getting blank screen. But the URL http://localhost:8081/index.android.bundle?platform=android&dev=false&hot=false&minify=false show the data

var __DEV__=false,__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now(),process=this.process||{};process.env=process.env||{};process.env.NODE_ENV='production';
(function (global) {
  'use strict';

  function _toConsumableArray(arr) {
    if (Array.isArray(arr)) {
      for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
        arr2[i] = arr[i];
      }

      return arr2;
    } else {
      return Array.from(arr);
    }
  }
...... and so on

mohdabbas avatar Feb 09 '18 13:02 mohdabbas

I`m facing this issue too

andfs avatar Feb 09 '18 22:02 andfs

In my project the problem was with react-native-vector-icons. The RN releases greater then 0.51 is hiding the real problem. I`ve downgraded the RN version and used this guides:

https://github.com/facebook/react-native/pull/17672/files https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-357493287

Then I`ve upgraded the RN version to 0.53 and almost everything is working fine. Now the problem is with the drawer

andfs avatar Feb 10 '18 11:02 andfs

I'm having the same problem. @mohdabbas, in the beginning, you are saying that this happens on Android only, and in the end, you are saying that it happens on both. Could you edit? it can create some confusion. :)

I get a blank white screen on react-native run-android, can't even access CMD+M for dev menu. IOS working perfectly fine.

React Native Navigation version: 1.1.375 React Native version: 0.52.0 Platform(s) (iOS, Android, or both?): both

FlaviooLima avatar Feb 24 '18 16:02 FlaviooLima

In my project the problem was with the icons when i comment this line

icon: require('./img/one.png'),

the project works fine on IOS but I get a blank white screen on android

You have to add icon so the tabulation can works on android

ibmouhssine avatar Mar 02 '18 06:03 ibmouhssine

@ibmouhssine I have this same issue, where exactly do I add icon: require('./img/one.png'), ?

arapocket avatar Mar 10 '18 01:03 arapocket

@FlaviooLima Where did I say that it happens on both?

My issue solved after deleting the virtual device and creating a new one! I faced the issue a couple of times, each time I delete the device and recreate, it solves. Strange :-).

mohdabbas avatar Mar 11 '18 14:03 mohdabbas

@mohdabbas If I delete the app it solves my issue too. Can you try to uninstall and see if it solves for you to? And if I have debugjs mode off it happen's a lot more this white screen. In the bottom of your comment Where you say the environment :)

Platform(s) (iOS, Android, or both?): both

It should be

Platform(s) (iOS, Android, or both?): Android

@arapocket I believe that @ibmouhssine was trying to say the icon in here:

this.props.navigator.setTabButton({
  tabIndex: 0, // (optional) if missing, the icon will be added to this screen's tab
  icon: require('../img/one.png'), // local image asset for the tab icon unselected state (optional)
  selectedIcon: require('../img/one_selected.png'), // local image asset for the tab icon selected state (optional, iOS only)
  label: 'New Label' // tab label that appears under the icon (optional)
});

But in my case my app doens't have tabs, maybe i'm missing something? i am new to this library.

FlaviooLima avatar Mar 12 '18 09:03 FlaviooLima

Getting same exact issue. iOS works fine, it's just Android. For me the app builds fine showing 100%, can't access the dev tools and the console is just empty.

"react-native": "0.53.0",
"react-native-navigation": "^1.1.408",

I had some icons on my tab bar, but even removing them doesn't fix the issue.

Edit: Actually the debugger can't connect to the emulator WebSocket connection to 'ws://localhost:8081/debugger-proxy?role=debugger&name=Chrome' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

varqasim avatar Mar 15 '18 09:03 varqasim

You must have the icons in android tab bar. I followed the links that I mentioned above and loaded the icons as follow:

Icon.getImageSource('ios-pricetag-outline', 30).then((promocoes) => { 
					promocoesIcon = promocoes;
Navigation.startTabBasedApp({
						tabs: [{
								label: 'Agora',
								screen: 'agora',
								title: 'Agora',
								icon: promocoesIcon,
								navigatorButtons
							}

andfs avatar Mar 15 '18 14:03 andfs

@andfs are you sure your problem was not related to - https://github.com/wix/react-native-navigation/issues/2180

Noitidart avatar Mar 21 '18 21:03 Noitidart

@Noitidart I think not because now everything works fine

andfs avatar Mar 22 '18 12:03 andfs

Same issue on Android with RN 0.54.0. The first time I open my app in the emulator it works fine, but upon subsequent restarts I get a white screen. If I uninstall the app in the emulator, then it works the first time I start the app but I just get white screens the next time.

Pastromhaug avatar Mar 26 '18 00:03 Pastromhaug

I am still unable to resolve this on Android, works fine in iOS

"native-base": "^2.3.9", "react": "^16.3.0-alpha.1", "react-native": "0.54.2", "react-native-vector-icons": "^4.5.0",

I have a tabConfig.js

import { default as MaterialIcons } from 'react-native-vector-icons/MaterialIcons';
async function prepareIcons() {
    const icons = await Promise.all([
        MaterialIcons.getImageSource('some-icon', 30),
        MaterialIcons.getImageSource('another-icon', 30)
    ]);
    const [someIcon, anotherIcon] = icons;
    return { someIcon, anotherIcon };
}

export async function getTabApp() {
    const icons = await prepareIcons();
    return {
        drawer: {
            left: {
                screen: 'drawer.Main'
            }
        },
        tabs: [
            {
                label: 'Tab1',
                screen: 'tab.SomeTab', // this is a registered name for a screen
                icon: icons.someIcon,
                // selectedIcon: icons.someIcon, // iOS only
                title: 'Tab 1'
            },
            ...
        ]
    }
}

And in index.js

import { getTabApp } from 'tabConfig';
async function startApp() {
    Navigation.startTabBasedApp(await getTabApp());
}
startApp();

hugheba avatar Mar 26 '18 18:03 hugheba

I am facing this issue too. It works fine on iOS, but I get blank screen on Android. "react-native": "0.54.2" "react-native-navigation": "^1.1.415" "native-base": "^2.3.10"

fivechjr avatar Mar 27 '18 07:03 fivechjr

In my case the issue was that I was using a variable that I didn't import in my Screens.js file but it didn't throw that error. It simply showed me white screen. Make sure there are no such error in your file else it will show white screen instead of throwing it.

V3RT1AG0 avatar Mar 27 '18 12:03 V3RT1AG0

I just downgraded React Native to 0.49 and it works normally on both iOS and Android. It seems that there might be something broken in React Native 0.5+ ?

fivechjr avatar Mar 27 '18 12:03 fivechjr

Was facing the same issue while using Navigation.startTabBasedApp so decided to try Navigation.startSingleScreenApp. It worked without a problem.

My current hypothesis is missing tab icons are to blame. I have not specified any, so maybe they fallback to some defaults. (Project I work with does not use new VectorIconsPackage()).

If this would help someone I can share the code of the project that reproduce the issue.

chrmod avatar Mar 27 '18 21:03 chrmod

From what I understand, this issue happens when an error is thrown, and because react-native activity is not initialized it breaks and don't show the error. I believe that most of this issues can be resolved if you find the code that is causing the error in your project and not in wix itself. But there are people here that may have found a true bug in this library. So just before starting to write here. Try to guarantee that the bug is not in your code. :)

FlaviooLima avatar Mar 28 '18 10:03 FlaviooLima

@FlaviooLima Even this one file app white-screens on Android, runs fine on iOS. I can't get much simpler than this.

index.js

import React from "react";
import { Text } from "react-native";
import { Navigation } from 'react-native-navigation';

class Simple extends React.Component {
    render() {
        return (<Text>Hello, I'm Simple.</Text>);
    }
}

Navigation.registerComponent('simple', () => Simple);
Navigation.startSingleScreenApp({
    screen: {
        screen: 'simple'
    }
});

No other code included, and I'm pretty sure all this is correct.

hugheba avatar Mar 28 '18 11:03 hugheba