Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make API javadocs for Google Play Services APIs and Firebase APIs show up in Android Studio rather than decompiled classes with no docs?

When I click on any Google Play Services API, or Firebase API that I'm using in my android project in Android Studio, the IDE takes me to a decompiled version of the class where the variable names are obfuscated and there are no docs on any of the methods. Any ideas how to see the docs directly in the IDE?

I suspect the reason is that play services and firebase services are not open source and I'm ok with not seeing the impls, I understand they want to protect that. But I'd really benefit from seeing the docs directly in the IDE rather than alt-tabbing to a browser. Thanks for your help.

like image 769
Creos Avatar asked Jul 09 '16 13:07

Creos


1 Answers

Javadocs really should be distributed with the client libraries. We have an open issue within Google on this, but I have no timelines on when a proper solution will be available. However, I can give you a workaround that you can apply to your project. It's not a great solution, but it's something.

On my OSX machine, the Android SDK is installed here:

/Users/[myusername]/Library/Android/sdk 

And the local copy for Play Services and Firebase javadocs are here (yours may vary):

/Users/[myusername]/Library/Android/sdk/extras/google/google_play_services/docs/reference/ 

You can actually attach this path to your Firebase client libraries in Android Studio with this procedure:

  1. Find Firebase/Play client libraries in the project view under "External Libraries".
  2. Right click the one you're most interested in seeing javadoc. For example, for Firebase Realtime Database, you can use "firebase-database-9.2.0".
  3. In the contextual menu, click Library Properties at the bottom.
  4. In the Library Properties window, there is a button that has a + sign. Click that. This lets you attach a javadoc path to classes in that library.
  5. Navigate/Paste your javadoc path from above into the dialog.
  6. In the next dialog, tell it "JavaDocs".

Now, when you summon javadoc for classes in that library, you'll see it. However, you'll have to do this for every library where you want javadoc.

If you don't have local javadocs installed for some reason, you can attach the remote url for the javadoc. For that, use the plus button with the little earth under it, and paste the javadoc url. For Firebase, that's https://firebase.google.com/docs/reference/android and for Play Services, that's https://developers.google.com/android/reference/

It's not great to do all this manual work, but at least it gets you javadoc in your IDE.

If you want to write a script to attach this for everything you use, know that this procedure essentially just modifies files under .idea/libraries. You can pretty easily observe the javadoc XML element that gets modified when you make changes in the IDE, and you can script/edit changes there yourself if you want.

like image 87
Doug Stevenson Avatar answered Oct 13 '22 05:10

Doug Stevenson