React-native: Button onPress not triggering in debug mode with Android device

Created on 18 Apr 2020  路  20Comments  路  Source: facebook/react-native

Description

Button onPress will not trigger in debug mode on. I created a brand new project with the cli tool and got it to run no my Android tablet. Added a button to the App.js template code:

Button Android

Most helpful comment

Same behaviour here after upgrading from 0.61.5 on Android. Disabling chrome debugging enables touches, while having debugging enabled disables touches. Buttons will show the ripple animation to indicate they have been touched, but no effect after that.

Edit: as a workaround, this seems to be working fine https://github.com/facebook/react-native/issues/27008#issuecomment-592048282

All 20 comments

I have the same problem. onPress is not triggered in debug mode (windows, chrome, android emulator). If debug mode is disabled onPress is working fine.

Same behaviour here after upgrading from 0.61.5 on Android. Disabling chrome debugging enables touches, while having debugging enabled disables touches. Buttons will show the ripple animation to indicate they have been touched, but no effect after that.

Edit: as a workaround, this seems to be working fine https://github.com/facebook/react-native/issues/27008#issuecomment-592048282

@zenibeat Thank goodness - I was going insane over this ... I couldn't find out why this was happening. Sometimes it would just work and other times you just get the button feedback (downstate) but onPress doesn't trigger ...
I also found out that if you are in debug mode but press the button from the very edge of the phone it will still work for some reason (testing on a Huawei P30 Pro)

The same happens to me if I use the debug mode (Huawei P20 Pro).
With react native 62.2

Same behaviour here after upgrading from 0.61.5 on Android. Disabling chrome debugging enables touches, while having debugging enabled disables touches. Buttons will show the ripple animation to indicate they have been touched, but no effect after that.

Edit: as a workaround, this seems to be working fine #27008 (comment)

The link solve my issue by disabling then enabling the automatic time in the android device settings

Have the same problem.
react: 16.11.0
react-native: 0.62.2
My phone: mi a2 lite

Temporary solution was using onPressIn instead.

Edit: as a workaround, this seems to be working fine #27008 (comment)

thanks!

@zenibeat Maddoc42
I have meet that issue and tried the solution @Maddoc42 but not working

@weinixuehao had this issue on multiple real android phones by now. What always seems to work is open phone settings --> date & time --> turn off "Use network provided time" and back on.

On some devices it takes a few tries to get this worked, sooner or later they all come around though 馃憤

@Maddoc42
Thanks! I also found a solution to reinstall after uninstalling the app then it is ok!

@weinixuehao can you please explain which solution you've used ?

@avinashlng1080
Reinstalling app when run into the issue. after all, this is only a small probability, so it is acceptable to me

This is certainly anything but acceptable ... this happens every single time I test it - how come there is still no fix for this? A lot of people must be facing this daily now

I can't fix it with the workaround solutions provided here the times never align the device is always one second behind the dev machine ...

Besides ... is this really the issue? Again I can click things always - but they will only trigger the onPress function if they are at the very border of the screen
To me this feels more like an invisible overlay that catches the click events

Hi, i am facing the same issue on iOS :/

first of all check adb date and your pc date with
adb shell "date" && date
if this dates are different, pc and device (real phone or emulator) set automatic network-provided time. Carefull both device(pc and phone or emulator.)
this works for me

Same Problem

Phone and device times are perfectly matching but the issue persists...
"react": "16.11.0", "react-native": "0.62.2"
Tested on Google Pixel 4a, Android 11

Come on React-Native Team, please help

good day
I am emulating on a physical android phone
I had the same problem
I solved it by exiting the application, deactivating it and reopening it
I hope it works for you

Try update CLI
Solved for my project.

For me, Changing the browser for debugging from Mozilla Firefox to Google Chrome fixed the problem for me

Was this page helpful?
0 / 5 - 0 ratings