58,454
社区成员
发帖
与我相关
我的任务
分享
private static String getAdbLocation() {
// String toolsDir = System.getProperty("com.android.uiautomator.bindir"); //$NON-NLS-1$ 这样是获取不到 adb的
// if (toolsDir == null) {
// return null;
// }
String toolsDir = "D:\\adt-bundle-windows-x86-20131030\\sdk\\tools"; //本机adb位置
File sdk = new File(toolsDir).getParentFile();
// check if adb is present in platform-tools
File platformTools = new File(sdk, "platform-tools");
File adb = new File(platformTools, SdkConstants.FN_ADB);
if (adb.exists()) {
return adb.getAbsolutePath();
}
// check if adb is present in the tools directory
adb = new File(toolsDir, SdkConstants.FN_ADB);
if (adb.exists()) {
return adb.getAbsolutePath();
}
// check if we're in the Android source tree where adb is in $ANDROID_HOST_OUT/bin/adb
String androidOut = System.getenv("ANDROID_HOST_OUT");
if (androidOut != null) {
String adbLocation = androidOut + File.separator + "bin" + File.separator +
SdkConstants.FN_ADB;
if (new File(adbLocation).exists()) {
return adbLocation;
}
}
return null;
}