user3395744
user3395744

Reputation: 1

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

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.

Upvotes: 0

Views: 9845

Answers (2)

jenkitay
jenkitay

Reputation: 45

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.

Upvotes: 0

Scott Barta
Scott Barta

Reputation: 80010

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.

Upvotes: 2

Related Questions