libadb-android icon indicating copy to clipboard operation
libadb-android copied to clipboard

W/System.err: java.lang.InterruptedException: Timed out while trying to find a valid host address and port

Open sd3970566 opened this issue 3 years ago • 6 comments

pair成功后报错 W/System.err: java.lang.InterruptedException: Timed out while trying to find a valid host address and port

sd3970566 avatar Oct 28 '22 03:10 sd3970566

Where are the additional logs? Please post in English (use a translator if you want). I don't understand your language, unfortunately.

MuntashirAkon avatar Oct 31 '22 16:10 MuntashirAkon

Most mobile phones in Chinese Mainland are not allowed to set the "wireless debugging page" split screen of the interface (nor can it be minimized. If you leave this page, the pairing code will disappear). I see that many of our peers connect pair by adding input boxes in the drop-down menu! Although the pairing can be successful, it can't be connected~I don't know how my peers achieve it. My technology is not as good as theirs

sd3970566 avatar Nov 02 '22 01:11 sd3970566

Where the code goes wrong

public void pair(int port, String pairingCode) {
            executor.submit(() -> {
                try {
                    boolean pairingStatus;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
                        AbsAdbConnectionManager manager = AdbConnectionManager.getInstance(getApplication());
                        pairingStatus = manager.pair(AndroidUtils.getHostIpAddress(getApplication()), port, pairingCode);
                    } else pairingStatus = false;
                    pairAdb.postValue(pairingStatus);


                    autoConnectInternal();//这行代码无法连接成功。报错W/System.err: java.lang.InterruptedException: Timed out while trying to find a valid host address and port


                } catch (Throwable th) {
                    th.printStackTrace();
                    pairAdb.postValue(false);
                }
            });
        }

sd3970566 avatar Nov 02 '22 01:11 sd3970566

Thanks for reporting. Yes, I have received report that in some devices, ADB connection appears to work only after restarting the app after pairing it. This might be an issue with the library itself. I shall look into it in my free time.

MuntashirAkon avatar Nov 04 '22 06:11 MuntashirAkon

I've tried reproduce this before publishing 2.2.1 using the test app, but was unable to reproduce it in the devices I have tried. However, in an actual implementation, App Manager, I was able to reproduce the issue at least once. I shall take some more time to figure out if this is actually something to do with the library or mDNS is just too lazy. But whatever the case is, do not expect mDNS to work all the time. It's better if you have a fail-safe mechanism i.e. a manual mechanism to insert the port address.

MuntashirAkon avatar Dec 09 '22 11:12 MuntashirAkon

Please check v2.2.2

MuntashirAkon avatar Mar 09 '23 09:03 MuntashirAkon