nohajc / termux-adb

Run adb in Termux without root permissions!
MIT License
391 stars 37 forks source link

Add workaround for Samsung devices #6

Open ShapeShifter499 opened 1 year ago

ShapeShifter499 commented 1 year ago

Due to some issue with the way samsung devices handles things. Unsure what exactly if I'm being honest ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot is needed to run termux-adb or adb in general through termux. Initially I didn't need it but now I notice it fails if I don't use that. I'm wondering if it would be possible to add some sort of detection for Samsung devices and have that automatically appended?

If not at least add a footnote to the readme about it.

EDIT:Fold 4 user

nohajc commented 1 year ago

Thanks for the report. I don't own any Samsung device, so I had no idea. Before I decide what to do about it, I'd like to understand more how this even works.

I already found some information but if you have any useful resources, you're welcome to share them.

RohitVerma882 commented 1 year ago

I haven't tried but I'm just asking, doesn't this work on all Samsung devices? Can this problem be solved by patching adb? Or is there no other solution other than fakeroot?

nohajc commented 1 year ago

I don't really know... Haven't got around to investigate this further.

CamsShaft commented 12 months ago

I'm using an S22 SM-S901W Snapdragon on android 14. Whenever I type in termux-adb it seems to be working. I'm still doing some research for my S10 G973U which is also Snapdragon android 12 and don't want to screw anything up. Haven't even plugged it in yet so here's hoping it's good news... Feel free to throw some advice my way since I don't even know if it'll work at all. All I want for Christmas is my OEM and bootloader unlocked!

Zorono commented 7 months ago

I can't run it anyway on my phone (Samsung A24 - Android 14)...

CANNOT LINK EXECUTABLE "termux-adb": cannot locate symbol "_ZN6google8protobuf8internal8TcParser15GenericFallbackEPNS0_11MessageLiteEPKcPNS1_12ParseContextENS1_11TcFieldDataEPKNS1_16TcParseTableBaseEm" referenced by "/data/data/com.termux/files/usr/bin/termux-adb"...
nohajc commented 7 months ago

This looks unrelated to Samsung. Do you have the latest version running? It's possible I'll need to do a new build. This linking issue happens from time to time when Termux updates the protobuf library.

CamsShaft commented 7 months ago

I can't run it anyway on my phone (Samsung A24 - Android 14)...

CANNOT LINK EXECUTABLE "termux-adb": cannot locate symbol "_ZN6google8protobuf8internal8TcParser15GenericFallbackEPNS0_11MessageLiteEPKcPNS1_12ParseContextENS1_11TcFieldDataEPKNS1_16TcParseTableBaseEm" referenced by "/data/data/com.termux/files/usr/bin/termux-adb"...

"pkg install android-tools" don't forget to split screen the first time you connect. Also after you do "adb pair ip:port pairing code" you have to run "adb connect ip:port". Every time after that all you need to do is turn on wireless debugging and "adb connect ip:port"

CamsShaft commented 7 months ago

Sorry @nohajc. Don't mean to step on any toes here, just trying to help. Rish is pretty easy to use to get a shell too

nohajc commented 7 months ago

I can't run it anyway on my phone (Samsung A24 - Android 14)...

CANNOT LINK EXECUTABLE "termux-adb": cannot locate symbol "_ZN6google8protobuf8internal8TcParser15GenericFallbackEPNS0_11MessageLiteEPKcPNS1_12ParseContextENS1_11TcFieldDataEPKNS1_16TcParseTableBaseEm" referenced by "/data/data/com.termux/files/usr/bin/termux-adb"...

"pkg install android-tools" don't forget to split screen the first time you connect. Also after you do "adb pair ip:port pairing code" you have to run "adb connect ip:port". Every time after that all you need to do is turn on wireless debugging and "adb connect ip:port"

I don't think the issue has anything to do with wireless debugging either. You should be able to use termux-adb for normal USB debugging.

These linking errors usually appear when there's an update of termux dependencies and it just means I have to compile my code again. Unfortunately, google's protocol buffer C++ library doesn't keep any binary compatibility.

nohajc commented 7 months ago

Anyway, this time I cannot reproduce it. I just did pkg upgrade and I'm running termux-adb 0.2.2-1 without issue.

Zorono commented 7 months ago

Anyway, this time I cannot reproduce it. I just did pkg upgrade and I'm running termux-adb 0.2.2-1 without issue.

i tried turning off 'Auto Blocker' (incase it is a security layer related issue) but it didn't help either...

Termux version: v0.118.0+8e3a898

nohajc commented 7 months ago

Is this some beta or a custom build?

When I run termux-info I get

TERMUX_VERSION=0.118.0

Zorono commented 7 months ago

Is this some beta or a custom build?

When I run termux-info I get

TERMUX_VERSION=0.118.0

a debug build from GitHub actions' artifact of commit 8e3a898

nohajc commented 7 months ago

That will be the problem. The way I build and release the package now, I can only support one revision at a time. That means it works with the current stable but it will most likely stop working soon as the changes you're building against make it to a release. At that point I'll make sure I update my repo too.

You'd basically have to do your own termux-adb build to have it running now. I'm not happy about the situation but unfortunately didn't have time to come up with a proper solution yet.

If termux-adb became part of the official Termux repository, it would solve all these issues. I didn't have such ambition so far though...

huynhtanloc2612 commented 6 months ago

Hi @nohajc , Thanks for making termux-adb which is what I am looking for a while. Is there any update on the release. I have just installed it which version is 0.2.1-3 on my Samsung phone (S22 Ultra - Android 14) and I see the similar error. CANNOT LINK EXECUTABLE "termux-adb": cannot locate symbol "_ZN6google8protobuf11MessageLite15ParseFromStringEN4absl12lts_2023080211string_viewE" referenced by "/data/data/com.termux/files/usr/bin/termux-adb"...

nohajc commented 6 months ago

Hi, I'm going to look into it.

nohajc commented 6 months ago

Ok, first, apologies for any confusion as I was previously referring to version 0.2.2-1 which is in fact not released.

I did however try with 0.2.1-3 and stable Termux (after pkg upgrade) and it doesn't give me the linker error.

Can you verify you're running Termux from F-Droid and not any custom build?

Also, which version of libprotobuf do you have?

It should be

$ pkg show libprotobuf Package: libprotobuf Version: 2:25.1 Maintainer: @termux

huynhtanloc2612 commented 6 months ago

Yes, I am using official Termux app from F-Droid And libprotobuf version is shown below:


Version: 2:25.1-1
Maintainer: @termux
Installed-Size: 6943 kB
Depends: abseil-cpp, libc++, zlib
Breaks: libprotobuf-dev, protobuf-static (<< 25.1)
Replaces: libprotobuf-dev
Homepage: https://github.com/protocolbuffers/protobuf
Download-Size: 1087 kB
APT-Manual-Installed: no
APT-Sources: https://termux.librehat.com/apt/termux-main stable/main aarch64 Packages
Description: Protocol buffers C++ library```
nohajc commented 6 months ago

Ok, turned out I was using a different repository mirror which wasn't exactly up to date. I switched to the official one, upgraded and now I can replicate your issue.

I'll make a new build ASAP. Thanks for reporting!

nohajc commented 6 months ago

@huynhtanloc2612 Try to upgrade now. Version 0.2.1-4 should fix the problem.

huynhtanloc2612 commented 6 months ago

@huynhtanloc2612 Try to upgrade now. Version 0.2.1-4 should fix the problem.

Great! Previous problem was fixed. There is no error now. I will do more tests with usb cable tomorrow (because I don't have any cable with me now) and let you know if it is ok. Thank you very much for your very fast support.

nohajc commented 6 months ago

I made another release (this time really 0.2.2) which should improve stability (i.e. things won't break every time Termux upgrades the problematic dependencies).

huynhtanloc2612 commented 6 months ago

@huynhtanloc2612 Try to upgrade now. Version 0.2.1-4 should fix the problem.

Great! Previous problem was fixed. There is no error now. I will do more tests with usb cable tomorrow (because I don't have any cable with me now) and let you know if it is ok. Thank you very much for your very fast support.

I have just tested with cable and saw that termux-adb (v0.2.1-4) could detect and connect with other devices successfully and adb commands work correctly. However, it took quite long time (around 30 seconds) from connecting the devices (phones) with usb cable to the time I could see connected devices appeared as a result of termux-adb devices command. Is it the issue or limitation? Thanks.

nohajc commented 6 months ago

30 seconds seems like too much... One thing you could try is to

  1. run termux-adb kill-server
  2. connect your device
  3. run termux-adb devices

On the first run, termux-adb should detect all connected devices relatively fast. If the server is already running, devices are checked periodically in the background but it should be more often than 30 s.

Sometimes, the phone's battery saving features can mess with the clock (like stopping the ticks or slowing them down) but this typically happens to me only when the display is off.

I'll try to play with it and see if I can reproduce any of that with the new version.

huynhtanloc2612 commented 6 months ago

I have tried above suggestion but device detection time is no change (still very slow) I also have tested termux-adb (v0.2.2-1) on other device (Xiaomi 6 Pro - Android 8.1.0) which works correctly and fast. Slowness may depend Android version or device manufactorer.

nohajc commented 6 months ago

Slowness may depend Android version or device manufactorer.

That was my theory too. Unfortunately, such problems may be very difficult to work around within Termux.

I suppose if somebody made a native ADB app designed for Android, it might give better results.

huynhtanloc2612 commented 6 months ago

Slowness may depend Android version or device manufactorer.

That was my theory too. Unfortunately, such problems may be very difficult to work around within Termux.

I suppose if somebody made a native ADB app designed for Android, it might give better results.

Can we feedback or suggest Termux developers about this issue of ADB so they can give good solution to overcome it and suggest integrating termux-adb to official Termux repo...as well? I think it will be great.

huynhtanloc2612 commented 6 months ago

Slowness may depend Android version or device manufactorer.

That was my theory too. Unfortunately, such problems may be very difficult to work around within Termux.

I suppose if somebody made a native ADB app designed for Android, it might give better results.

@nohajc I have just found that the slowness happened with termux-usb command. I tried termux-usb -l, it took the same amount of wating time before the result appeared and then I tried termux-adb devices the connected devices were showed as a result. So I guess issue of slowness is termux-usb Hope it give you some ideas.

nohajc commented 6 months ago

@nohajc I have just found that the slowness happened with termux-usb command. I tried termux-usb -l, it took the same amount of wating time before the result appeared and then I tried termux-adb devices the connected devices were showed as a result. So I guess issue of slowness is termux-usb Hope it give you some ideas.

Can I ask you to report it in the termux repo? With the information about your device etc.

I can try to talk to someone about integration to the official repository in the meantime.

Thanks!

huynhtanloc2612 commented 6 months ago

@nohajc I have just found that the slowness happened with termux-usb command. I tried termux-usb -l, it took the same amount of wating time before the result appeared and then I tried termux-adb devices the connected devices were showed as a result. So I guess issue of slowness is termux-usb Hope it give you some ideas.

Can I ask you to report it in the termux repo? With the information about your device etc.

I can try to talk to someone about integration to the official repository in the meantime.

Thanks!

Yes, I have just reported this https://github.com/termux/termux-api/issues/680