40

I am working on project which is shared by few developers, how to get to know about developer blame in android studio?? any shortcuts or any idea? which will help us to know about code blame.

Vinod Pattanshetti
  • 2,465
  • 3
  • 22
  • 36

3 Answers3

107

Use Annotate feature of Android Studio

1.Right click in line number pane

enter image description here:

2.Select Annotate

enter image description here

rcde0
  • 4,192
  • 3
  • 21
  • 31
  • 1
    Ya this is a feature of android studio I was looking for thanks @rcde0. – Vinod Pattanshetti Apr 03 '17 at 09:25
  • Any idea what to do if this stops working for some unknown reason? The project is setup fine with VCS and integrated correctly (can show history/commit/etc) but the `Annotate` is greyed-out. Disclaimer: it was working fine until two days ago so i really have no clue what went wrong. – Shark Jun 26 '17 at 17:42
  • @Shark, have a look at this [answer](https://stackoverflow.com/questions/35206015/intellij-annotate-option-grayed-out) . – rcde0 Jul 11 '17 at 09:53
  • Thanks but I fixed it last week. – Shark Jul 11 '17 at 12:04
  • can we view this the a Intellij IDEA shows it (like a comment after every line of code) – nyxee May 27 '20 at 08:16
  • Tell Rishi to use string resources! Classic Rishi. – Vinay W Jul 02 '21 at 10:30
  • Is there a keyboard shortcut to show/hide this? – SMBiggs Jan 13 '22 at 16:43
  • @SMBiggs - never used that, this might help : https://developer.android.com/studio/intro/keyboard-shortcuts#configure_custom_keymaps – rcde0 Jan 22 '22 at 22:28
  • @rcde0 Thanks, that's a very useful link! But I had already figured it out and posted the keyboard-shortcut solution below. https://stackoverflow.com/a/70705190/624814 – SMBiggs Jan 23 '22 at 00:02
  • 1
    @SMBiggs Awesome, and my bad, did not see that earlier. – rcde0 Jan 23 '22 at 20:52
1

You can install GitToolBox plugin to view code blame on every cursor position.

OR

you can view by right clicking on left gutter in android studio, you will have a pop-up with option for Annotation or Annotate with Git Blame.

Amir Raza
  • 2,320
  • 1
  • 23
  • 32
1

In addition to rcde0's answer, which I use all the time. You can also add a keyboard shortcut to toggle this view.

  1. Preferences -> Keymap to bring up this screen: enter image description here

  2. Type "annotate" in the search area. This will find all commands that refer to the word in the search box.

  3. Click on Git->Git->Annotate, this will bring up the first popup, asking how to proceed.

  4. Select "Add Keyboard Shortcut" like I did here:

enter image description here

  1. Another modal window will pop up, asking you to type in a keyboard shortcut. Select the area I'm pointing to and simply type your keyboard shortcut. You can see that I typed ctrlA. I never use it to jump to the beginning of the line, so this works well for me. enter image description here

  2. If the keystroke is already defined, it will warn you. Feel free to try other keystrokes until you find one that suits your style without eliminating something that you use for other things. Click OK to reassign the keystroke.

  3. You'll now see your new keystroke mapped to the various "Annotate" functions. Hit 'OK' to exit preferences.

  4. Try it out. Type your newly-defined keystroke and see the Annotations in the left gutter toggle on and off.

SMBiggs
  • 11,034
  • 6
  • 68
  • 83