Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio is making used import statement as unused?

I have just starting working my android studio project in another pc with same android studio version and it automatically makes used import statement as unused in the code and mark evey code related to particular import statement red. How can i fix this issue , its very annoying. but when i run the project ,it works fine without any error.

I have tried all those tricks including deleting .ide ,.gradle and even restarting with invalidate cash ,restard and disabling automatic import as well.

In the below screenshot , android studio just grayout all import statment i am using below and mark all those classes and its related method red in the code. how can i fix this issue

screenshot

like image 885
tomtom Avatar asked Aug 31 '25 21:08

tomtom


2 Answers

MyAppObserver is unused import because you import it in the same file it's declared. As for others I am not sure because I can't see full file structure.

like image 74
Nazarii Moshenskiy Avatar answered Sep 03 '25 09:09

Nazarii Moshenskiy


Your interface of the same name is causing a conflict.

interface MyAppObserver

Rename your interface and the imports should work correctly, and the red marks should go away.

like image 21
Jens Zalzala Avatar answered Sep 03 '25 09:09

Jens Zalzala