Chimerapps / drift_inspector

Library and UI to inspect moor at runtime
MIT License
3 stars 0 forks source link

ADB/iDevice path not found in IntelliJ plugin #10

Open kuhnroyal opened 3 years ago

kuhnroyal commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

It also is not showing any Android emulator or devices.

NicolaVerbeeck commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

NicolaVerbeeck commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

NicolaVerbeeck commented 3 years ago

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.

kuhnroyal commented 3 years ago

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

NicolaVerbeeck commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

kuhnroyal commented 3 years ago

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