NoReadAccessException-允许从事件分发线程或仅在内部读取操作进行读取访问

时间:2018-11-28 13:00:13

标签: android gradle android-studio-2.2 android-gradle-2.2

系统/ api配置

Android studio version : 2.2.3
Gradle version : 2.2.1
Java version : 1.8
classpath 'com.android.tools.build:gradle:1.3.1'

例外

18:26:43 NoReadAccessException
         Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
         Details: Current thread: Thread[ApplicationImpl pooled thread 20,4,main] 700161407
         ; dispatch thread: false; isDispatchThread(): false
         SystemEventQueueThread: Thread[AWT-EventQueue-0 2.2#AI-145.3537739 Studio, eap:false, os:Windows 10 10.0, java-version:JetBrains s.r.o 1.8.0_76-release-b03,6,main] 1350276257

当我尝试运行应用程序时,出现了此问题,任何人都可以知道我为解决此问题所做的事情。

1 个答案:

答案 0 :(得分:0)

您可以使用:

 SwingUtilities.invokeLater(() -> {
      // your code here
 });