madb icon indicating copy to clipboard operation
madb copied to clipboard

Device always invalid on Ubuntu

Open KthProg opened this issue 7 years ago • 23 comments

Here is the problem line.

Splitting on Environment.NewLine, or including "\r" would fix the issue. Ubuntu (and Linux in general) uses "\r" for newlines. Otherwise t gets one long string and fails to match the RegEx.

KthProg avatar May 23 '18 16:05 KthProg

Here's the PR

KthProg avatar May 23 '18 16:05 KthProg

I take it back, this might not quite be the issue. Let me investigate some more.

KthProg avatar May 23 '18 17:05 KthProg

So I am not understanding how this fixes it... it currently splits on \r\n or \n, Environment.NewLine should only be \n on linux, \r\n on windows.

camalot avatar May 23 '18 17:05 camalot

ok, now, i see your new message.

camalot avatar May 23 '18 17:05 camalot

Yeah I'm apparently very wrong lol. It is having an error at the parsing stage (most likely when it splits) for some reason, but I'm not sure why yet (checking the regex shows that it does match the adb devices output).

KthProg avatar May 23 '18 17:05 KthProg

can you put the error that you are seeing in this issue

camalot avatar May 23 '18 17:05 camalot

If it was splitting correctly, then the RegEx should be successful (I tested it against the output of adb devices)

KthProg avatar May 23 '18 17:05 KthProg

There's an outside possibility that something different is being returned from adb than I'm seeing, but I can't imagine why that would be.

KthProg avatar May 23 '18 17:05 KthProg

can you post the value that is coming in in data. feel free to XXXX out any values if you want.

camalot avatar May 23 '18 17:05 camalot

Lemme see. I'm running it through a test adapter so I'll have to create a new project to call it directly.

KthProg avatar May 23 '18 17:05 KthProg

It doesn't look like I can debug that code from the package. I can pull down the code locally and try that. I don't know if it will build though since it isn't .NET Core.

KthProg avatar May 23 '18 17:05 KthProg

Yeah I can't build it outside of a .NET Core project. So there's no way for me to tell really. Is there any way you could push up a NuGet with some logging?

KthProg avatar May 23 '18 18:05 KthProg

Hello. Did you get a chance to look at this? I don't have any way of figuring out what the input was.

KthProg avatar May 24 '18 16:05 KthProg

Hey. Just following up. Any chance to look into this?

KthProg avatar May 25 '18 18:05 KthProg

no permissions

This is due to adb not being started with elevated permissions. I don't know if ManagedAdb automatiaclly runs the kill-server and start-server commands at some point. (I hope not?)

But if not, starting adb with sudo privileges at boot-time would resolve this issue. If so, the library should at least throw a warning that it tried to start adb in elevated mode but a password was requested.

adb kill-server
sudo `which adb` start-server

You can make an entry in the ect/sudoers.d folder to skip the password requirement for sudo adb. You should refactor your project into a more debuggable form for situations like this. This is the easiest solution assuming you aren't in a non-sudo Linux system, like Fedora.

Other approach is to add yourself to plugdev group and put adb executable under non-root owner.

sudo usermod -aG plugdev kthprog
sudo chown kthprog `which adb`
sudo chgrp kthprog `which adb`
sudo chmod 775 `which adb`

gamesguru avatar May 25 '18 22:05 gamesguru

Weird. It works fine when I run adb myself. I don't think adb is being run under my account. I'll sort through the code and figure out what it's running under.

KthProg avatar May 26 '18 19:05 KthProg

if you run adb yourself with the devices you have at work attached, i expect some will return 'no permission'

looks like there are 5 references to either Stop() or Restart() in AndroidDebugBridge.cs

what's curious is StartServer() is a totally empty method. I had had this problem with the library in the past, on Tony's app, that it wouldn't start a server but depended on one running already. So i had to ALWAYS start it from command prompt. Pretty stupid really

Assuming it does issue the kill server command, the best option is probably a simple python script running in the background which constantly checks for devices with 'no permissions' and restarts the server with sudo priviledges if this ever happens. You can put the python script in your startup commands on Ubuntu.

gamesguru avatar May 26 '18 19:05 gamesguru

Initially I thought it might be best to fix this issue in the library itself under a new fork, but you're right, it's probably best to just put a nice little script on the Linux box.

KthProg avatar May 29 '18 16:05 KthProg

I'm getting this error again now on Windows. Even though the list comes up fine in cmd

KthProg avatar Oct 26 '18 15:10 KthProg

that's because no one has pushed a commit to this repo in 3 years. Anyone who would use it for Android 9 is a fool

make your own wrapper and you will be thankful

gamesguru avatar Oct 26 '18 15:10 gamesguru

Lmao sup Shane. Didn't know it was that out of date. Seems too buggy to keep using

KthProg avatar Oct 26 '18 16:10 KthProg

it's also possible no commits have been pushed because it is already perfect. you should ask the maker directly what's up @camalot

gamesguru avatar Oct 28 '18 02:10 gamesguru