11

Below in the image 1 you can see I created a Kotlin class that extends from the Application() class: screenshot from Android Studio 3.1.2

I also added the necessary stuff in my Manifest file as you can see in the next image: Manifest file

However I can't figure out why Android Studio maintains that I am NOT using my Class at all! It is underlined and grayed out and on mouse over you see the message "Class XZY is never used."

The same behavior I noticed in Versions of Android Studio different from my current one, which is 3.1.2. Of note might be that if I create the same class in Java, Android Studio functions as it should and knows that I use the class if I mention it in my Manifest file. Any ideas how to convince the Android Studio that I am actually using this class?

Hoornet
  • 1,398
  • 3
  • 18
  • 30

3 Answers3

3

This is a bug in Android Studio. Here is a link to Google Issue Tracker (requires Google account). It was reported there by a few users in March 2018 and got little attention from Google staff ever since.

NickM_RG
  • 29
  • 3
  • 1
    Thanks for sharing the answer on stackoverflow. Please read this article on [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer), especially the part: `Provide context for links`. Good luck! – Stephan T. Mar 19 '19 at 11:24
  • @NickM_RG : yeah. I believe it was my own report that was included ... :) – Hoornet Mar 20 '19 at 13:41
1

That is bug and it's not yet solved what i did was adding this line before the class

@Suppress("unused")
Stephen
  • 415
  • 7
  • 8
0

Try to select Invalidate Caches/Restart from menu File tab.

GBDevs
  • 86
  • 4