Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run adb shell "date `date +%m%d%H%M%Y.%S`"

I have a warning when running React Native on an Android device:

Debugger and device times had drifted by more than 60s. Please correct this by running adb shell "date `date +%m%d%H%M%Y.%S`" on your debugger machine

But when I run the command as suggested above, I get and operation not permitted error:

date: cannot set date: Operation not permitted

I already tried with sudo, still got same result:

sudo adb shell "date `date +%m%d%H%M%Y.%S`" 
like image 756
vun Avatar asked Aug 14 '16 03:08

vun


Video Answer


2 Answers

Inside the emulator goto Settings > Date & Time

  1. Deselect Automatic timezone.
  2. Adjust your timezone manually.
  3. Deselect automatic date & time and set correct time
like image 84
atinder Avatar answered Oct 19 '22 10:10

atinder


Deselecting automatic time and time zone did not work for me. Instead, I did adb shell su root date $(date +%m%d%H%M%Y.%S).

Adding "su root" is the solution to the "Operation not permitted" error.

Note that this is not equivalent to executing adb shell first and then su root date $(date +%m%d%H%M%Y.%S) (in this case $(date +%m%d%H%M%Y.%S) returns the emulator time, which is not correct, so even though the command succeeds, it does not fix the problem).

like image 41
Andrii Chernenko Avatar answered Oct 19 '22 10:10

Andrii Chernenko