Skip to content
New issue

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

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

Already on GitHub? # to your account

Regex for Android bundle id causing failures #924

Closed
tomatobrown opened this issue Sep 4, 2018 · 17 comments
Closed

Regex for Android bundle id causing failures #924

tomatobrown opened this issue Sep 4, 2018 · 17 comments

Comments

@tomatobrown
Copy link

tomatobrown commented Sep 4, 2018

Using Mac - High Sierra

Description

Line 113 of src/devices/android/ADB.js is:
const bundleIdRegex = pipeCommands.escape.inQuotedRegexp(bundleId) + '[ ]*$';

I'm not sure what the '[ ]*$' is for, or maybe I'm building my application incorrectly. I'm only able to get detox 9.0.1 to work correctly when I delete the + '[ ]*$' from that file. I know this is somewhere between and an issue and a question, but can someone clear this up for me.

Sample error:
detox[9144] ERROR: [exec.js/EXEC_FAIL, #19]
detox[9144] ERROR: [exec.js/EXEC_FAIL, #20] "/Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"" failed with code = 1, stdout and stderr:

@noomorph
Copy link
Collaborator

noomorph commented Sep 5, 2018

Okay, let's debug it.

Run your app on the emulator and run the command you mentioned

/Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"

Does it print more specific errors?

@tomatobrown
Copy link
Author

tomatobrown commented Sep 5, 2018

Thanks noomorph, when I run

tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal"
u0_a679   9208  1184  1406708 151692 ffffffff b7671255 S com.myapp.myappportal
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):

No error message returns, it just makes a new line.

@tomatobrown
Copy link
Author

tomatobrown commented Sep 5, 2018

For what it's worth, the old way works

tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal\\s*$"
u0_a679   9208  1184  1406708 151692 ffffffff b7671255 S com.myapp.myappportal
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):

@noomorph
Copy link
Collaborator

noomorph commented Sep 5, 2018

@tomatobrown , weird. Can you pipe adb -s emulator-5554 shell ps into a file and send it as-is in an attachment, please? Need to see in hex

@tomatobrown
Copy link
Author

here it is @noomorph
adp_ps.txt

@noomorph
Copy link
Collaborator

noomorph commented Sep 5, 2018

Thanks. I'll look at it first thing tomorrow

@noomorph
Copy link
Collaborator

noomorph commented Sep 6, 2018

@tomatobrown , I've found the issue. Your ps output somehow returns ^M line breaks (with DOS endings). I have no slightest idea why but I'll try to extend the regexp for this case.

@tomatobrown
Copy link
Author

Thanks @noomorph and for what it's worth, I've confirmed that this same issue exists on at least 3 other Mac's other than mine, so I think the issue might be bigger than it appears.

@noomorph
Copy link
Collaborator

noomorph commented Sep 6, 2018

It's still weird nevertheless. I hope to finish the PR soon, but out of curiosity what emulator and SDKs are you using? On our CI it passes alright and locally I could not reproduce. Thanks for dumping adb ps output into a file. Otherwise, I would not be able to fix your issue.

@tomatobrown
Copy link
Author

I've been using a Nexus 5 - with Android 7.1.1 (Nougat)

@fschindler
Copy link

@DanielMSchmidt could you please take a look

@noomorph
Copy link
Collaborator

@tomatobrown , I have one more request, could you dump also your

adb shell dumpsys power

into a text file as-is?

@noomorph
Copy link
Collaborator

noomorph commented Sep 13, 2018

@tomatobrown , I was looking at this StackOverflow issue and it made me wonder... which shell you are using? Are you sure your tty is not something exotic?

@tomatobrown
Copy link
Author

Here it is:
shell_dump.txt

I'm just using the terminal on High Sierra

@noomorph
Copy link
Collaborator

noomorph commented Sep 13, 2018

@tomatobrown , something's wrong... it has DOS CRLF line endings too. It's not good. If my memory does not fail me, you're the first developer who reports this particular issue.

Should I tell you that I have more than four different PCs (running Windows 10, Ubuntu 18.04, MacOS Sierra, MacOS High Sierra) in my household + I look at our Jenkins CI? And still I was not able to reproduce your issue... What is even worse - I just have realized that in order to fix it, I might need to rewrite the whole ADB helper class in Detox. And that won't get me closer to the source of your issue, which is very daunting.

One more thing. Dump this command adb exec-out dumpsys power into a file, please. I hope it will have LF endings, otherwise your emulator is weird.

And ping me directly (the email is in my profile). I might need your further assistance in this later on.

Thanks for the cooperation.

@DanielMSchmidt
Copy link
Contributor

DanielMSchmidt commented Sep 13, 2018 via email

@noomorph noomorph self-assigned this Sep 15, 2018
@ikabelerma
Copy link

ikabelerma commented Sep 17, 2018

This also happened to both our build and local tests. The only strange behavior that it works for apks built for debug but not for release ones. We're using MacOS High Sierra iTerm/Terminal.

Out stop gap solution was to downgrade to v8.0.0

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

6 participants