Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.20] [Android] screenPhysicalPixels undefined #5963

Closed
mikefowler opened this issue Feb 16, 2016 · 23 comments
Closed

[0.20] [Android] screenPhysicalPixels undefined #5963

mikefowler opened this issue Feb 16, 2016 · 23 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@mikefowler
Copy link
Contributor

Changes in 228a1fe appear to have broken Android. The requiring of Dimensions throws the following error:

undefined is not an object (evaluating 'screenPhysicalPixels.width')

screen shot 2016-02-16 at 12 41 35 pm

@facebook-github-bot
Copy link
Contributor

Hey mikefowler, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@ames89
Copy link

ames89 commented Feb 16, 2016

+1

I'm having the same issue, on the file react-native/Libraries/Utilities/Dimensions.js

in the object

dimensions.screen = {
width: screenPhysicalPixels.width / screenPhysicalPixels.scale,
height: screenPhysicalPixels.height / screenPhysicalPixels.scale,
scale: screenPhysicalPixels.scale,
fontScale: screenPhysicalPixels.fontScale,
};

@gre
Copy link
Contributor

gre commented Feb 16, 2016

Just reached the same problem. Any workaround?

@gre
Copy link
Contributor

gre commented Feb 16, 2016

Ok I think actually it's a caching bug. I've removed the app from my phone and it worked.
make sure you also npm install from scratch

@RyanMitchellWilson
Copy link

Just tried removing the app, installed fresh node modules and reinstalled the app to the emulator and I'm still getting the same error.

@mikefowler
Copy link
Contributor Author

I've also repeated similar steps to no avail:

  1. Removed app from device
  2. Stopped packager
  3. rm -rf $TMPDIR/react-* to clear packager cache
  4. rm -rf node_modules && npm install to reinstall all dependencies
  5. npm start
  6. react-native run-android

Same error.

@southerneer
Copy link

Same here. Tried @mikefowler 's steps and same result.

@paulbao
Copy link

paulbao commented Feb 17, 2016

same Issue, my workaround is change it to:
// if (Platform.OS === 'android') {
// // Screen and window dimensions are different on android
// var screenPhysicalPixels = dimensions.screenPhysicalPixels;
// dimensions.screen = {
// width: screenPhysicalPixels.width / screenPhysicalPixels.scale,
// height: screenPhysicalPixels.height / screenPhysicalPixels.scale,
// scale: screenPhysicalPixels.scale,
// fontScale: screenPhysicalPixels.fontScale,
// };

// // delete so no callers rely on this existing
// delete dimensions.screenPhysicalPixels;
// } else {
dimensions.screen = dimensions.window;
// }

in 'Libraries/Utilities/Dimensions.js'

@rameshvishnoi90904
Copy link

@paulbao it worked.

@paulbao
Copy link

paulbao commented Feb 17, 2016

Could you please help to confirm if it works now?

@rameshvishnoi90904
Copy link

@paulbao i am using android device and its working fine along with react-native @0.20

@paulbao
Copy link

paulbao commented Feb 17, 2016

@rameshvishnoi90904 Yes, you are right mate. I just forget to change dependencies.
compile "com.facebook.react:react-native:0.20.+"
I guest we all made the same mistake.

@xfworld
Copy link

xfworld commented Feb 17, 2016

+1

@pppluto
Copy link

pppluto commented Feb 17, 2016

@rameshvishnoi90904 @paulbao you're right. 🍻

ceichinger pushed a commit to elbstack/react-native that referenced this issue Feb 17, 2016
@RyanMitchellWilson
Copy link

@satya164 why was this closed? This hasn't been fixed yet and I'd really rather not have to dig into my node_modules and fix the code everytime I reinstall them.

@gre
Copy link
Contributor

gre commented Feb 18, 2016

@RyanMitchellWilson actually there are no bugs. grep for 0.19, you probably have an old version somewhere.

@mikefowler
Copy link
Contributor Author

Confirmed. Though it's unclear if we all did something wrong or if react-native upgrade failed to update the string in android/app/build.gradle.

@sreesharp
Copy link
Contributor

Confirmed. Updating build.gradle works.

@paulbao
Copy link

paulbao commented Feb 18, 2016

@mikefowler I updated react-native manually and it's my mistake not to update build.gradle also.

@zxcpoiu
Copy link
Contributor

zxcpoiu commented Feb 19, 2016

confirmed.

At first, I update react native only by change dependency in packge.json then just npm install again, it did NOT update build.gradle for you. That's what I was doing wrong.

If you are just running example or simple project without any specific settings, maybe it's proper to use react-native upgrade, it will detect conflicts and ask your confirm to overwrite like:

 conflict .gitignore
? Overwrite .gitignore? do not overwrite
     skip .gitignore

 conflict ios/project.xcodeproj/project.pbxproj
? Overwrite ios/project.xcodeproj/project.pbxproj? overwrite
    force ios/project.xcodeproj/project.pbxproj

 conflict android/app/build.gradle
? Overwrite android/app/build.gradle? overwrite
    force android/app/build.gradle

 conflict android/app/proguard-rules.pro
? Overwrite android/app/proguard-rules.pro? overwrite
    force android/app/proguard-rules.pro

bin-liu added a commit to bin-liu/react-native that referenced this issue Feb 22, 2016
The version of 0.17 will cause error ("undefined is not an object (evaluating 'screenPhysicalPixels.width')") when run to devices/simulator.
also see facebook#5963
ghost pushed a commit that referenced this issue Feb 22, 2016
Summary:The version of 0.17 will cause error ("undefined is not an object (evaluating 'screenPhysicalPixels.width')") when run to devices/simulator.
also see #5963
Closes #6076

Differential Revision: D2960511

fb-gh-sync-id: bd71de789fa1501b285b9bde01cf12ab9ce75888
shipit-source-id: bd71de789fa1501b285b9bde01cf12ab9ce75888
@kunkun12
Copy link

change android/app/build.gradle file compile "com.facebook.react:react-native:0.20.+" has solved

@aoriani
Copy link

aoriani commented Feb 23, 2016

Can someone point out which exact version of react-native fixes it? 0.20.1? Using + is discouraged and gives you a nice lint warning. I prefer to have a fixed version.

@aoriani
Copy link

aoriani commented Feb 23, 2016

Okay. I verified that compile 'com.facebook.react:react-native:0.20.1' does the job.

christopherdro added a commit to react-native-maps/react-native-maps that referenced this issue Mar 2, 2016
pglotov pushed a commit to pglotov/react-native that referenced this issue Mar 15, 2016
Summary:The version of 0.17 will cause error ("undefined is not an object (evaluating 'screenPhysicalPixels.width')") when run to devices/simulator.
also see facebook#5963
Closes facebook#6076

Differential Revision: D2960511

fb-gh-sync-id: bd71de789fa1501b285b9bde01cf12ab9ce75888
shipit-source-id: bd71de789fa1501b285b9bde01cf12ab9ce75888
BigPun86 pushed a commit to BigPun86/react-native-maps that referenced this issue Dec 1, 2016
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests