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

Android Blank Screen On Require

Open edo1493 opened this issue 11 years ago • 10 comments

Hi guys, I have this: var companiespicker = require('./components/companiespicker');

on the third line of my index.android.js.

If I keep it, I get a blank grey screen. If I remove it, I can actually see what should be rendered in the index and the app actually works.

If I debug in chrome (with the line not commented out) and run the app again in the simulator, I don't get the blank screen, but the app is extremely slow (dev tools prob).

Since I am writing the Android version of an iOS app, I have decided to run the same code, with the same require on an iPhone 6 simulator, it works.

I am pretty sure the problem isn't with the code or the require (the file is where it should be) and I don't see how this could be a react issue. I am running 0.11.0. I have tried to update to the latest releases 0.12.0 and 13, but this causes other problems that are not even related to this one.

Any ideas?

screen shot 2015-10-22 at 17 33 58

edo1493 avatar Oct 22 '15 16:10 edo1493

Can you look at the logs? Run adb logcat.

mkonicek avatar Oct 22 '15 22:10 mkonicek

This might sound random but do you have a stylesheet in the component that has a style with a duplicate or something else malformed? I had an issue where if I had duplicate entries in the style object it would fail silently exactly like this whenever a module containing such a broken stylesheet was included. Try commenting things out in the component file and removing the comments piece by pice

mangogogos avatar Oct 23 '15 22:10 mangogogos

Are you using Navigator? I think I usually get this when using a component that has not been required in a scene rendered by the navigator.

cosmith avatar Oct 24 '15 08:10 cosmith

I have just run ads logical. I think these lines (https://gist.github.com/edo1493/bb780aaa79ea229f2fa2) are pretty interesting but I don't get why it fails to find "require".

edo1493 avatar Oct 24 '15 08:10 edo1493

The funny thing is that before requiring the companies picker, I do have another require:

var tabs = require('./tabsAndroid/tabs.android'); //var companiespicker = require('./components/companiespicker');

so why would it say "can't find variable require"? I thought I had mistyped something, but this syntax works smoothly on iOS and also with debugging in chrome open. >.<

edo1493 avatar Oct 24 '15 08:10 edo1493

I am getting closer. In the companiesPicker, I am requiring this:

var tabBarios = require('../tabs/tabs.ios'); and when I remove it, the whole thing works.

That's probably why I am also getting:

E/ReactNative( 1963): Got JS Exception: SyntaxError: Attempted to redefine property 'usersEvent'.

which is defined in that component. I think I can manage to fix it, but still don't get why the code works smoothly in iOS and complains when I run it on Android (only by requiring it), cause I am really not even touching that component.

edo1493 avatar Oct 24 '15 08:10 edo1493

Attempted to redefine property 'usersEvent' is definitely the problem. Look for all occurrences of usersEvent in your code. The difference between iOS and Android could be that you have some platform-specific files?

mkonicek avatar Oct 26 '15 23:10 mkonicek

I found the problem, I was defined the same prop twice in the iOS file. However what got me thinking was the fact that Xcode wasn't complaining and the android version was working with the chrome dev tools open, which is weird.

edo1493 avatar Oct 27 '15 17:10 edo1493

Glad you found the problem. @foghina has a task to show a redbox instead of blank screen on syntax errors. That should make debugging issues like this much easier.

Not sure what was different in Xcode, let's discuss in a separate issue should we get a minimal repro.

mkonicek avatar Oct 27 '15 23:10 mkonicek

Same issue here, I declared style prop twice after removing the unused one problem solved. The main issue is red screen does not give a proper definition in linux environment. It only warns the property style is redefined but does not point to anywhere in the source. Thanks for the info here, it was helpful to investigate the problem and solve it.

cubbuk avatar Mar 07 '16 10:03 cubbuk