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

Button onPress not triggering in debug mode with Android device #28687

Closed
zenibeat opened this issue Apr 18, 2020 · 30 comments
Closed

Button onPress not triggering in debug mode with Android device #28687

zenibeat opened this issue Apr 18, 2020 · 30 comments
Labels
Component: Button Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@zenibeat
Copy link

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 title="My Button" onPress={() => console.log("pressed")}/>
"pressed" showed up in the log with Debug off, but did not with Debug on.

I tried the above with rn version 0.61.5 and it worked great in Debug mode.

Same as this: https://stackoverflow.com/questions/61189313/react-native-buttons-onpress-does-not-fire-when-app-running-in-debug-mode

React Native version:

System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
Memory: 1.55 GB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 23, 24, 26, 27, 28
Build Tools: 23.0.1, 26.0.1, 28.0.2, 28.0.3
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_131 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. create new project with the cli
  2. Add a button to the App.js template code:
    <Button title="My Button" onPress={() => console.log("pressed")}/>

Expected Results

Expected "pressed" to appear in Chrome debugger.

@majugurci
Copy link

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.

@Maddoc42
Copy link

Maddoc42 commented Apr 20, 2020

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)

@Dinkelborg
Copy link

@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)

@adrianm86
Copy link

adrianm86 commented Apr 27, 2020

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

@eggybot
Copy link

eggybot commented Apr 28, 2020

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

@Battleplayer
Copy link

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

Temporary solution was using onPressIn instead.

@naxel
Copy link
Contributor

naxel commented May 14, 2020

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

thanks!

@weinixuehao
Copy link

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

@Maddoc42
Copy link

@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 👍

@weinixuehao
Copy link

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

@avinashlng1080
Copy link

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

@weinixuehao
Copy link

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

@Dinkelborg
Copy link

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

@StarryFire
Copy link

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

@OkancanCosar
Copy link

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

@SchmidiMC
Copy link

Same Problem

@SamiChab
Copy link

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

@carrillojeisson93
Copy link

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

@fcostaprojects
Copy link

Try update CLI
Solved for my project.

@salman1696
Copy link

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

@supostat
Copy link

supostat commented Jan 7, 2021

Any updates ?
Just faced with the same issue on IOS. Not on simulator, on real device.

@encouver
Copy link

Same issue here for Android 10 and React Native with expo.

@fabOnReact
Copy link
Contributor

alexciarlillo #27008 (comment) searches for a solution for this issue

I believe I ended up tracking this down to an issue with there being a time difference between the host and device. Since the time is off, the calculation for whether it was a short press or long press is broken (or something like that). You can verify this by running adb shell "date" && date to see if the times are off. I think I was usually able to fix this by going into the device settings, disabling automatic time resolution, and then re-enabling it. I think there was also a way to do this via an adb command but can't recall what it is.

@joshwinter
Copy link

Toggling my automatic time resolution, toggling my mac automatic time resolution and restarting my device (important) worked for me. Thanks for help on this page.

@withzhaoyu
Copy link

meet same issue .

@MustafaAnasKH99
Copy link

Toggling my automatic time resolution, toggling my mac automatic time resolution and restarting my device (important) worked for me. Thanks for help on this page.

This worked for me. however, now I cant fetch data. It says my time is ahead. lol

@md-amil
Copy link

md-amil commented Feb 22, 2022

in my case button onpress not triggring when i make a build in debugging mode working fine

@AudreyHepbur
Copy link

I used "react-native-elements": "^3.4.2", TabView caused this problem, just update to the latest version

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 22, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Button Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests