Android studio 3.3 Go to Declaration does not work
Asked Answered
C

3

8

Today, I upgrade stable release of Android Studio 3.3 and then I realize that the common action go to declaration by Cmd + Left Click or Cmd + B does not work anymore. Instead, It goes to declaration in R.java

Now, I must double shift on layout/drawable/mipmap file to go to it's declaration. But, this action does not work with resource id/color/string... So, now it is hard to find out input value from resource.

Is there anyway to make this function back? I think it really helpful.

Any suggestion is appreciate

Confederacy answered 29/1, 2019 at 9:53 Comment(2)
Having same issue. did u find any solution?Panthia
i got solution please check my answer belowPanthia
P
12

I have faced same issue. After spending so much time on this i found proper solution for this.

1). Upgrade your project gradle like

 classpath 'com.android.tools.build:gradle:3.3.0'

If this not work than try below method

2). Just delete

.gradle
.idea
build 

folder from your project and reopen the project. and it will solve this issue.

If you have multiple module in your project than remove all those folder from all modules.

Hope this will work for you as it worked for me.

Panthia answered 30/1, 2019 at 9:45 Comment(4)
thank you, for your suggestion. My solution is just close & reopen android studio several timesConfederacy
@DMonkey please update your gradle classpath 'com.android.tools.build:gradle:3.3.0'Panthia
@Lokesh Invalidate caches and restart with all you described seems to solve the issue, thanksAntherozoid
for me all three deleted works thank youEmelyemelyne
O
6

Its not removed. Its working fine.

You can do following things:

  1. You can restart Android Studio
  2. May be you are clicking on removed ID or STRING or COLORS. So may be that is available in R.java but removed from directory. You can clean project and try again.
  3. Even If its not working, You can use Invalidate Cache and Restart option.

Hope 2nd point is happened to you.

Thank you.

Olympiaolympiad answered 31/1, 2019 at 12:33 Comment(2)
File > Invalidate Caches / Restart fixed the issue for me on Android Studio 3.5.Mystic
The Invalidate Caches / Restart... fixed the issue for me on Android Studio 4.2.1.Araucania
D
-1

Press Ctrl + Shift + A, and search for the command you're looking for ("declaration") for example. This finds the command "Declaration - Goto by Reference action - Ctrl + B".

So you just need to put your cursor on the method you want to go to, and press Ctrl + B? You can also Ctrl + Click to achieve the same goal.

The most useful keyboard shortcuts are described in the Help

NOTE:- Please restart your studio & wait until Gradle will be built successfully.

Dyadic answered 29/1, 2019 at 10:53 Comment(1)
This doesn't solve the problem, but is a shortcut to highlight the problem. Instead of the goto declaration going to a layout xml file, it now goes to the declaration in the generated R.java file.Antherozoid

© 2022 - 2024 — McMap. All rights reserved.