I tried to create java app fro connecting to Android device.
Here is the code:
public class Main { public static void main(String[] args) throws IOException { AndroidDebugBridge.initIfNeeded(false); AndroidDebugBridge adb = AndroidDebugBridge.createBridge("C:\\install\\adt-bundle-windows-x86_64-20130917\\sdk\\platform-tools\\adb.exe", true); if (adb == null) { System.err.println("Invalid ADB location."); System.exit(1); } IDevice[] iDevices = adb.getDevices(); AndroidDebugBridge.addDeviceChangeListener(new AndroidDebugBridge.IDeviceChangeListener() { @Override public void deviceChanged(IDevice device, int arg1) { // not implement } @Override public void deviceConnected(IDevice device) { System.out.println(String.format("%s connected", device.getSerialNumber())); } @Override public void deviceDisconnected(IDevice device) { System.out.println(String.format("%s disconnected", device.getSerialNumber())); } }); } }
Starting the program returns the error:
Failed to parse the output of 'adb version'
Solution is found on stackoverflow Failed to parse the output of ‘adb version’?
The problem was in COMODO Antivirus. Steps to do in the answer http://stackoverflow.com/a/8988993.
- run comodo settings
- defense+
- list active processes
- add adb.exe to trusted processes
- restart server: run “adb kill-server” “adb start-server”