Android Studio // Import statement error // Unused import statement

99封情书 提交于 2020-01-06 11:09:25

问题


Everytime I want to import anything the import statement line just disappears and gives me the following error:

Access is allowed from event dispatch thread only.
     Details: Current thread: Thread[JobScheduler FJ pool 7/8,6,main] 1239762171
     Our dispatch thread:Thread[AWT-EventQueue-0 0.5.1#AI-134.1061098, eap:true,6,main] 198746559
     SystemEventQueueThread: Thread[AWT-EventQueue-0 0.5.1#AI-134.1061098, eap:true,6,main] 198746559

Any solution for that?

Thank you.


回答1:


This is bug https://code.google.com/p/android/issues/detail?id=66854; the workaround is to disable the "Optimize imports on the fly" preference until we get it fixed.




回答2:


This is because you have "Optimize imports on the fly" enabled, which automatically removes unused imports. You likely also have "Add unambiguous imports on the fly" selected, which automatically adds imports you need. The solution is to write the code first, and watch your imports be added automatically, and manually add any ambiguous ones, as they become needed. https://www.jetbrains.com/idea/help/creating-and-optimizing-imports.html?search=optim

In the event this does not work for you, or if you simply prefer to enter your own import statements, then simply disable the features in settings > Editor > Auto Import.



来源:https://stackoverflow.com/questions/22267839/android-studio-import-statement-error-unused-import-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!