升級到AndroidStudio最新版本(>3.2)朋友們都會遇到一個問題,找不到DDMS [Android Device Monitor], 只能從SDK目錄下找到 monitor 啓動DDMS [Android Device Monitor],因此寫了一個插件快速啓動Android Device Monitorandroid
開發工具:IntelliJ IDEA PS: 若是有須要的朋友歡迎留言git
Github地址:https://github.com/hi-dhl/DeviceMonitorPlugingithub
插件下載地址:https://github.com/hi-dhl/DeviceMonitorPlugin/releases/download/1.0/DeviceMonitorPlugin.jar bash
安裝方式:ide
如何啓動:工具
PS: Google雖然刪除了AdnroidStudio啓動入口,可是本地SDK中仍是存在,插件經過動態獲取本地SDK路徑啓動AndroidDeviceMonitor, 因爲電腦性能不一樣,啓動速度會有不一樣性能
Android Developers官網上的原文連接開發工具
Android Device Monitor是一個Android應用調試和分析工具提供了一個UI工具,可是大部分組件在Android Studio 3.1已經棄用了, 而且會在Android Studio 3.2中移除,將會用新的工具幫助開發人員調試和分析Android應用,詳情戳這裏ui
public class Monitor extends AnAction {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
try {
Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);
String os = AndroidUtils.getPlatformName();
String sdkPath = AndroidUtils.getApkLocalProperties(project);
if (os.toLowerCase().startsWith("win")) {
sdkPath += File.separator + "tools" + File.separator + "monitor.bat";
} else {
sdkPath += File.separator + "tools" + File.separator + "monitor";
}
Runtime.getRuntime().exec(sdkPath);
} catch (Exception e) {
}
}
}
複製代碼
/**
* 動態獲取本地Android SDK的路徑
*
* @param project
* @return
*/
public static String getApkLocalProperties(Project project) {
String sdkPath = "";
try {
String path = project.getBasePath() + File.separator + "local.properties";
Properties properties = new Properties();
InputStream inputStream = new FileInputStream(path);
properties.load(inputStream);
sdkPath = properties.getProperty("sdk.dir");
} catch (Exception e) {
}
return sdkPath;
}
複製代碼