19

When I find the declaration in themes_holo.xml(a Android system's file), Intellij tell me :

cannot find declaration to go to

Here is the code mentioned:

<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>
HalfLike
  • 219
  • 1
  • 2
  • 7
  • after trying several things I realized I was trying to this with a JavaScript file...well I wish it worked but it ain't gonna in android Studio as far as i know – CrandellWS Mar 07 '21 at 23:09

7 Answers7

26

I had the same problem, here is what fixed it for me:

  1. close the project in intellij.
  2. close intellij.
  3. go to the project folder and delete the .idea folder
  4. restart intellij and open the project (wait for the indexing to finish) and it would work.
areim
  • 3,371
  • 2
  • 23
  • 29
timmy_stapler
  • 547
  • 7
  • 15
  • This broke me Android project (Android Studio 3.3). Don't do it! – Ivo Stoyanov Feb 05 '19 at 13:55
  • 2
    Thank u , this method properly solves my problem! – Cyrus Mar 25 '19 at 16:45
  • I checked this way, but it didn't work for me. My Android Studio is v3.6.2. Thanks. – Muhammad Ali Apr 07 '20 at 07:29
  • maybe you also need to delete the .iml file also, make sure you delete both that file and the .idea directory only after you quit the IDE. – timmy_stapler Apr 12 '20 at 07:08
  • this only work if we close all the android studio project opened (close android studio not close project). this solve my problem.after reopening android studio it works. other wise project not identified in flutter project case – lava Jul 20 '21 at 19:09
13

Please try "File --> Invalidate Caches..." and restart IDE. It worked for me. Android Studio v3.6.2

Muhammad Ali
  • 720
  • 8
  • 21
4

I had the same problem, I used following steps:

  1. Go to File
  2. Select Power save mode option
  3. Disable the power save mode

This is worked for me and for suggestion.

Yashoda Bane
  • 399
  • 4
  • 7
  • I checked this way, but it didn't work for me. My Android Studio is v3.6.2. Thanks. – Muhammad Ali Apr 07 '20 at 07:31
  • It's actually the only method which worked for me. "Intelligent" auto switching for Power Save mode is a great thing indeed. – Alex Apr 14 '20 at 15:08
0

I already met this problem yesterday,but it isn`t absolutely similar to yours, and I searched nothing for help.Finally I resoved this by myself. Here is my XML file:

<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"/>

When I try to click the word "HardcodeText", it tells me "cannot declaration to go to", and it tells me that "checks references injected by IntelliLang plugin".

The problem comes from the XML settings,here`s my Android studio settings find this: editor-Inspections:searching xml,and you find this:Android-Android Resources Validation ,check it,and you will find Unknow Android XML attribute,check it

editor-Intentions:find XML-Set Namespace Prefix to empty,check this there will no warning line tell you checks references injected by IntelliLang plugin.and "cannot declaration to go to" because it quotes the official DTD or other thing,just ignore it if there is no warning line.

bummi
  • 27,123
  • 14
  • 62
  • 101
0

idea.max.intellisense.filesize = 99999

adding the above line in idea.properties solved the issue

Sunil Kumar S C
  • 296
  • 2
  • 12
0
  1. first check androidx is import your Gradle file
  2. clean -> and -> Rebuild your project
  3. Go to error xml file
  4. check xml in error use ctrl-right click its --> show android studio cannot find declaration to go to
  5. change the tag file like android.support.v7.widget.Toolbar to androidx.appcompat.widget.Toolbar
SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
-1

This work for me:

  1. close android studio
  2. go to C:\Users(your user)
  3. remove .AndroidStudio3.4 folder.

Then run android studio.

If this doesn't work, first uninstall android studio then repeat above steps

slfan
  • 8,950
  • 115
  • 65
  • 78
Reza Mojed
  • 657
  • 1
  • 7
  • 16