Android的工作室 - 模糊的方法调用的getClass() [英] Android Studio - Ambiguous method call getClass()

查看:302
本文介绍了Android的工作室 - 模糊的方法调用的getClass()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android工作室为我的Andr​​oid应用程序。
我的code ++工程,并编译。
近日,IDE showes我的错误(红色线)上的以下code的getClass:

I'm using Android Studio for my Android application.
My code works and compiles.
Recently, the IDE showes me error (red lines) on getClass of the following code:

fragment.getClass().getSimpleName()

不过还是应用程序编译和运行。
错误是:

But still the application compiles and runs.
The error is:

Ambiguous method call. Both
getClass () in Object and
getClass () in Object match.

能否有人解释我是什么呢?以及为什么code仍在运行?

Can some one explain me what is it about? and why the code still running?

推荐答案

我认为这是Android的Studio中的一个错误。我们知道,Android的工作室是基于的IntelliJ平台上的IntelliJ IDEA社区版的现有功能。

I think it is a bug in Android Studio. As we know, Android Studio is based on the IntelliJ Platform and the existing functionality of IntelliJ IDEA Community Edition.

谷歌已经开发出它与JetBrains公司的合作。而同样的错误报道发生在的IntelliJ为好。 看一看在错误报告

Google has developed it in cooperation with JetBrains. And same bug is reported to happen in IntelliJ as well. Have a look at the Error report

唯一解决方法这个问题是投你叫的getClass()上的实例,以对象如下:

The only workaround to this issue is to cast the instance you call getClass() on, to Object as follows:

((Object) this).getClass()

这篇关于Android的工作室 - 模糊的方法调用的getClass()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆