Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

ADB/iDevice path not found in IntelliJ plugin #10

Open
kuhnroyal opened this issue Jan 18, 2021 · 30 comments
Open

ADB/iDevice path not found in IntelliJ plugin #10

kuhnroyal opened this issue Jan 18, 2021 · 30 comments
Assignees

Comments

@kuhnroyal
Copy link

I didn't find a place to report problems with the IntelliJ plugin so i'll post here for now.
When I try to connect, the IntelliJ dialog displays ADB/iDevice path not found with a yellow warning sign.

I am not sure what to do, this worked previously at some point.
Any ideas?

@NicolaVerbeeck
Copy link
Contributor

Can you go the the IntelliJ settings -> Other settings -> Moor inspector. There should be a button to test/adapt your configuration.

@kuhnroyal
Copy link
Author

Didn't see this before. Same thing there. My colleague has the same result in the settings but he can connect to a device.
I will try to manually configure.

@NicolaVerbeeck
Copy link
Contributor

Does it say anything specific in the test configuration results? Can you include it here?

@kuhnroyal
Copy link
Author

No but now I configured the correct ADB path and installed libimobiledevice via brew. My colleague hasn't done this and can connect. For me it isn't even listing the device.
I am testing with an attached iPad.

Testing ADB
=======================================
ADB defined at path: /Users/foo/Library/Android/sdk/platform-tools/adb
ADB path seems ok
Checking adb command
Starting adb server
Listing devices
ADB devices returns: 0 device(s)

Testing iDevice
=======================================
iMobileDevice folder defined at path: /usr/local/bin
ideviceinfo seems ok
iproxy seems ok
idevice_id seems ok

@NicolaVerbeeck
Copy link
Contributor

Curious, perhaps he had it installed as a transitive dependency from somewhere else.

As I don't have a readily available iPhone or iPad lying around I can't really check right now. When working with the inspector I am usually running on an ios simulator anyway.

I will have to find some time/devices to see if I can reproduce it

@NicolaVerbeeck
Copy link
Contributor

@kuhnroyal can you provide me the output of: idevice_id -l

@kuhnroyal
Copy link
Author

I have restarted everything, disabled MacOs firewall but no success.

$ idevice_id -l                                                                                                                             1 ↵  10151  16:08:40 
34c3e41ae86f22a8063d05026e056b391d61068f

I have 2 iOS simulators running and one attached device. This is the device that is returned.

iPad Pro (12.9-inch) (2nd gen) (mobile)                    • 34c3e41ae86f22a8063d05026e056b391d61068f • ios         • iOS 14.0.1
iPhone 11 Pro Max (mobile)                                 • 8FDA16EA-3C61-4DE3-BB5B-C9F0CD5A13F6     • ios         • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
iPad Pro (12.9-inch) (4th generation) (mobile)             • 664ACE11-3C4C-4947-BBE4-BBE2C5DF0E7C     • ios         • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)

@kuhnroyal
Copy link
Author

It also is not showing any Android emulator or devices.

@NicolaVerbeeck
Copy link
Contributor

Ok, so it is finding the connected device (idevice_id never finds simulators, they work differently).
What does adb devices return as output?
Are you running any apps at that time that use the moor_inspector dart library? This is required for them to show up in the device explorer.

@kuhnroyal
Copy link
Author

Yes the app is running, I also verified that the "server started with port number" appears in the logs.

$ adb devices                                                                                                                                   10153  16:10:40 
List of devices attached
emulator-5554	device

@NicolaVerbeeck
Copy link
Contributor

If you try to connect directly to the ipad by entering the port number you see in the logs and it's IP address, does it work then?
The idevice and adb commands are used internally to setup a reverse TCP tunnel to facilitate this for you but manual mode 'should' work. If this works (or does not), we are zeroing in on the issue. Note that this does not work for simulators/emulators.

@kuhnroyal
Copy link
Author

kuhnroyal commented Jan 18, 2021

If you try to connect directly to the ipad by entering the port number you see in the logs and it's IP address, does it work then?

No, I have tried this but I will try again with the disabled firewall.

@NicolaVerbeeck
Copy link
Contributor

I don't know about your network setup, but on LAN the firewall should not kick in.

@kuhnroyal
Copy link
Author

Yea it should not and it also didn't change anything.
Copied the port number directly from the output.
Bildschirmfoto 2021-01-18 um 17 57 42

I don't know... since it doesn't work with simulator either, it is probably something weird.

@NicolaVerbeeck
Copy link
Contributor

Well, it does not help that I was trying to parse the IP address as the port number 🤦 I will fix this in a new release but this takes time as it needs to be reviewed by JetBrains.

If you still happen to have an ios simulator running could you run the following command:
echo -e '\x01' | nc localhost 6395
This will trigger all local running processes that have moor_inspector on to report their connection information.

Eg: echo -e '\x01' | nc localhost 6395 [{"packageName":"com.test","port":57213,"pid":-1,"protocol":1,"extensions":[{"name":"tag","data":"NTM4OTJi"}]}]

@kuhnroyal
Copy link
Author

Hmm that worked for the simulator, also seems to work every time I reinstall.

@NicolaVerbeeck
Copy link
Contributor

Ok, so it seems the library is working, that's something. So now we need to figure out why it is not showing up on your device explorer...

In IntelliJ -> Help -> Diagnostic Tools -> Debug Log Settings (that the path for the most recent IntellIJ version at least). You can add categories to log. Add: com.chimerapps. Then try to connect using the plugin and see if there is something related in the IntelliJ logs (or append them here if they contain no sensitive information)

@kuhnroyal
Copy link
Author

Need to clarify my last statement. After I executed the command, the device shows up in the plugin. And it works with this simulator afterwards without the command.

Gonna test more tomorrow.

@NicolaVerbeeck
Copy link
Contributor

That's great to hear, even though it makes zero sense to me why that would have worked 🤔

@kuhnroyal
Copy link
Author

Tested again with real devices and 0.1.3 of the plugin but no success.
The device is not showing up, so I can't connect automatically.
Manual connect attempt just closes the window and nothing happens.

There is nothing in the logs after enabling logging, just some Git/Sonar plugins.

2021-01-20 15:06:59,639 [4215094]   INFO - lij.diagnostic.DebugLogManager - Set TRACE for the following categories: com.chimerapps 

@NicolaVerbeeck
Copy link
Contributor

If your devices are on the same network, can you execute echo -e '\x01' | nc <deviceip> 6395 and see if that returns anything?

@kuhnroyal
Copy link
Author

Yes it does:

$ echo -e '\x01' | nc 192.168.178.125 6395                                                                                          0|SIGINT(2) ↵  10216  16:15:24 
[{"packageName":"com.example","port":52932,"pid":-1,"protocol":1,"extensions":[{"name":"icon","data":"Zmx1dHRlcg=="},{"name":"tag","data":"MzhkMDMx"}]}]%

But nothing in the plugin window and no manual connection with ip/port possible.

@NicolaVerbeeck
Copy link
Contributor

Do you have a proxy set in your IntelliJ by any chance? That's the only thing I can imagine right now why it would not work on your setup: sockets created from inside the IDE cannot access your localhost (that does not make any sense to me though)

@kuhnroyal
Copy link
Author

Nope, does the plugin start the announcement server and the devices register with it or how does this work?

@NicolaVerbeeck
Copy link
Contributor

The devices themselves run a single announcement server per device (using automatic master/slave primary/secondary architecture). The plugin loops over all found devices (adb devices, idevices, localhost) and asks the announcement server about all the running clients on that device (this echo -e '\x01' | nc ...). The way it connects to the announcement server is by creating a TCP proxy to the target device (using iproxy, adb forward or without proxy for localhost) to the announcement port (6395). This proxy forwards localhost connections to that port so plugin and device can communicate directly.

That means that if for some reason, the plugin cannot connect a TCP socket on the address returned by the JVM's InetAddress.getLoopbackAddress(), the discovery can never work. The fact that it works on terminal (without the reverse proxy, true) indicates that the system can connect, just the plugin can't.

@NicolaVerbeeck NicolaVerbeeck self-assigned this Jan 20, 2021
@kuhnroyal
Copy link
Author

Thanks for the explanation. I will try tu run some tests with real android devices tomorrow.
iOS simulators now consistently show up.

@NicolaVerbeeck
Copy link
Contributor

I have just released another update to the plugin, I am afraid it does not address the issues you have been having as I am still not sure how/why this is happening.

Any luck during testing?

@rajumb502
Copy link

Hi, does this plugin work on Windows? I am using Android Studio 4.2 Beta4 and use only for Android app development. How should I configure the 'select a device to connect to' options. I was able to get the emulated devices IP from Phone status but not sure what port I should use.

@NicolaVerbeeck
Copy link
Contributor

@rajumb502 please do not highjack an unrelated ticket to ask for help, create a new one instead.

@kuhnroyal
Copy link
Author

I tried this again today with 0.2.0 but no luck.
It seems the server port on the iPad is not open or not listening. I did a port scan on the device IP.

flutter: Server running on 50877
Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-26 13:33 CEST
Nmap scan report for 192.168.178.125
Host is up (0.0061s latency).
Not shown: 998 closed ports
PORT      STATE SERVICE
49152/tcp open  unknown
62078/tcp open  iphone-sync

Nmap done: 1 IP address (1 host up) scanned in 14.47 seconds

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants