尝试在 Android Studio 中进行 运行 项目时 InstantRunNotificationTask 出现 NullPointerException

NullPointerException in InstantRunNotificationTask when trying to run project in Android Studio

每当我 运行 我的项目出现这些细节时,我都会在 Android Studio 中收到错误消息:

null
java.lang.NullPointerException
    at com.android.tools.idea.run.tasks.InstantRunNotificationTask.<init>(InstantRunNotificationTask.java:63)
    at com.android.tools.idea.fd.InstantRunBuildAnalyzer.getNotificationTask(InstantRunBuildAnalyzer.java:178)
    at com.android.tools.idea.run.AndroidLaunchTasksProvider.getTasks(AndroidLaunchTasksProvider.java:120)
    at com.android.tools.idea.run.LaunchTaskRunner.run(LaunchTaskRunner.java:102)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:726)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:176)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:137)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:334)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

我已经尝试重新安装 SDK、插件并重新启动一切。不确定还有什么问题。

  • 前往 Preferences
  • 然后在 Build, Execution, Deployment 部分下,您将看到 Instant Run 部分。
  • 取消选中 Enable Instant Run... 复选框,然后再次尝试构建您的项目。