getClass() in abstract class gives Ambiguous method call

后端 未结 5 1584
北海茫月
北海茫月 2021-01-31 13:39

I have a public abstract class and I\'m trying to use the getClass() method, as I will need info from the class extending my abstract class. An example is this:

5条回答
  •  一向
    一向 (楼主)
    2021-01-31 14:00

    Casting my getClass() call to Object like this

    ((Object) this).getClass()
    

    solves the problem (with non abstract classes) for me. It's not great, but it's working.

    Also, manipulating your Android SDKs from the project settings and removing all JDK jars from your Android SDK resolves the error. Of course you'll have to reference it within your project to utilize the fix.

提交回复
热议问题