【问题标题】:intellij say "cannot find declaration to go to" in android xml file [duplicate]intellij 在 android xml 文件中说“找不到要转到的声明”[重复]
【发布时间】:2014-12-14 15:41:41
【问题描述】:

当我在themes_holo.xml(Android 系统的文件)中找到声明时,Intellij 告诉我:

找不到要前往的声明

这里是提到的代码:

<style name="Theme.Holo.Light.Dialog">
    <item name="windowFrame">@null</item>
    <item name="windowTitleStyle">@style/DialogWindowTitle.Holo.Light</item>
    ...
    <!-- I wang to find declaration of PreferencePanel.Dialog -->
    <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
</style>

【问题讨论】:

  • 在尝试了几件事之后,我意识到我正在尝试使用 JavaScript 文件来实现这一点......我希望它可以工作,但据我所知,它不会在 android Studio 中运行

标签: android xml intellij-idea


【解决方案1】:

我遇到了同样的问题,这是为我解决的问题:

  1. intellij 中关闭项目。
  2. 关闭智能
  3. 进入项目文件夹,删除.idea文件夹
  4. 重启intellij并打开项目(等待索引完成),它会工作。

【讨论】:

  • 这打破了我的 Android 项目 (Android Studio 3.3)。不要这样做!
  • 谢谢你,这个方法很好地解决了我的问题!
  • 我以这种方式检查过,但它对我不起作用。我的 Android Studio 是 v3.6.2。谢谢。
  • 也许您还需要删除 .iml 文件,请确保仅在退出 IDE 后删除该文件和 .idea 目录。
  • 这只有在我们关闭所有打开的 android studio 项目时才有效(关闭 android studio 而不是关闭项目)。这解决了我的问题。重新打开 android studio 后它可以工作。颤振项目案例中未确定的其他明智项目
【解决方案2】:

请尝试“File --> Invalidate Caches...”并重新启动 IDE。它对我有用。 Android Studio v3.6.2

【讨论】:

  • 它对我有用。 Android Studio 3.6.1
  • 谢谢。这对我使用 AS 4.2.2 有所帮助。
【解决方案3】:

我遇到了同样的问题,我使用了以下步骤:

  1. 转到文件
  2. 选择省电模式选项
  3. 禁用省电模式

这对我有用,也适用于建议。

【讨论】:

  • 我以这种方式检查过,但它对我不起作用。我的 Android Studio 是 v3.6.2。谢谢。
  • 这实际上是唯一对我有用的方法。省电模式的“智能”自动切换确实是一件很棒的事情。
【解决方案4】:

我昨天已经遇到了这个问题,但它与您的问题并不完全相似,我没有寻求任何帮助。最后我自己解决了这个问题。 这是我的 XML 文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#ff0d17ff"
tools:ignore="HardcodedText"
tools:context=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"
    android:background="#ff0d17ff"/>

当我尝试单击“HardcodeText”一词时,它告诉我“无法声明去”,它告诉我“检查由 IntelliLang 插件注入的引用”。

问题来自 XML 设置,这是我的 Android Studio 设置 找到这个: editor-Inspections:search xml,你会发现这个:Android-Android Resources Validation ,检查一下,你会发现Unknow Android XML attribute,检查一下

editor-Intentions:find XML-Set Namespace Prefix to empty,检查这个 不会有警告行告诉您检查 IntelliLang 插件注入的引用。以及“无法声明去”,因为它引用了官方 DTD 或其他内容,如果没有警告行,则忽略它。

【讨论】:

    【解决方案5】:

    idea.max.intellisense.filesize = 99999

    在idea.properties 中添加上述行解决了这个问题

    【讨论】:

      【解决方案6】:
      1. 首先检查 androidx 是导入你的 Gradle 文件
      2. clean -> 和 -> 重建你的项目
      3. 转到错误 xml 文件
      4. check xml in error use ctrl-right click its --> show android studio cannot find declaration to go to
      5. 将android.support.v7.widget.Toolbar等标签文件修改为androidx.appcompat.widget.Toolbar

      【讨论】:

        【解决方案7】:

        这对我有用:

        1. 关闭安卓工作室
        2. 转到 C:\Users(您的用户)
        3. 删除 .AndroidStudio3.4 文件夹。

        然后运行android studio。

        如果还是不行,先卸载android studio再重复以上步骤

        【讨论】:

        • 这真的很有效
        猜你喜欢
        • 2022-12-15
        • 1970-01-01
        • 1970-01-01
        • 2022-12-22
        • 1970-01-01
        • 1970-01-01
        • 2018-05-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多