问题
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