IllegalArgumentException:由于上次更新支持库时出错,无法找到 adb

IllegalArgumentException: Unable to locate adb due to error in the last update on support library

点击更新更新一些 android SDK 包后,当我打开 android studio 并尝试 运行 任何应用程序时,这就是我得到的:

IllegalArgumentException: Unable to locate adb

详情如下:

在“详细信息”选项卡中:

Unable to locate adb
java.lang.IllegalArgumentException: Unable to locate adb
    at com.android.tools.idea.run.editor.DeployTargetPickerDialog.<init>(DeployTargetPickerDialog.java:133)
    at com.android.tools.idea.run.editor.ShowChooserTargetProvider.showPrompt(ShowChooserTargetProvider.java:98)
    at com.android.tools.idea.run.AndroidRunConfigurationBase.getDeployTarget(AndroidRunConfigurationBase.java:475)
    at com.android.tools.idea.run.AndroidRunConfigurationBase.getState(AndroidRunConfigurationBase.java:294)
    at com.intellij.execution.runners.ExecutionEnvironment.getState(ExecutionEnvironment.java:158)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:55)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:50)
    at com.intellij.execution.ProgramRunnerUtil.executeConfiguration(ProgramRunnerUtil.java:118)
    at com.intellij.execution.impl.ExecutionManagerImpl.start(ExecutionManagerImpl.java:117)
    at com.intellij.execution.impl.ExecutionManagerImpl.access0(ExecutionManagerImpl.java:67)
    at com.intellij.execution.impl.ExecutionManagerImpl.run(ExecutionManagerImpl.java:509)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:222)
    at com.intellij.util.Alarm$Request.run(Alarm.java:378)
    at com.intellij.openapi.application.TransactionGuardImpl.run(TransactionGuardImpl.java:291)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:326)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:310)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access0(EventQueue.java:97)
    at java.awt.EventQueue.run(EventQueue.java:709)
    at java.awt.EventQueue.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我向 google 报告错误,我尝试卸载并安装所有:sdk-build-tools 和 sdk-platform-tools 但同样的错误仍然存​​在。

经过大量调查,此错误是由于上次更新时未完成安装 sdk-platform-tools 而发生的,当我尝试卸载它并从 Android studio 重新安装时 UI 发生意外行为。

所以解决方案是在Android Studio 中打开终端并编写以下命令来安装sdk-platform-tools:

android update sdk --no-ui --filter platform-tools