MuntashirAkon / libadb-android

ADB library for Android
Other
215 stars 50 forks source link

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

Open sd3970566 opened 1 year ago

sd3970566 commented 1 year ago

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

MuntashirAkon commented 1 year ago

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

sd3970566 commented 1 year ago

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 commented 1 year ago

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);
                }
            });
        }
MuntashirAkon commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Please check v2.2.2