问题描述
当我点击我在 Android Studio 的 android 项目中使用的任何 Google Play 服务 API 或 Firebase API 时,IDE 会将我带到类的反编译版本,其中变量名称被混淆并且没有任何方法的文档.任何想法如何直接在 IDE 中查看文档?
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?
我怀疑原因是 play 服务和 firebase 服务不是开源的,我可以没有看到实现,我知道他们想要保护它.但我真的受益于直接在 IDE 中查看文档而不是按 alt-tab 键切换到浏览器.感谢您的帮助.
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.
推荐答案
Javadoc 确实应该与客户端库一起分发.我们在 Google 内部有一个未决问题,但我没有关于何时可以使用适当解决方案的时间表.但是,我可以为您提供一个可以应用于您的项目的解决方法.这不是一个很好的解决方案,但它是一些东西.
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.
在我的 OSX 机器上,Android SDK 安装在这里:
On my OSX machine, the Android SDK is installed here:
/Users/[myusername]/Library/Android/sdk
Play 服务和 Firebase javadoc 的本地副本在这里(您的可能有所不同):
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/
您实际上可以通过以下步骤将此路径附加到 Android Studio 中的 Firebase 客户端库:
You can actually attach this path to your Firebase client libraries in Android Studio with this procedure:
- 在外部库"下的项目视图中找到 Firebase/Play 客户端库.
- 右键单击您最想查看 javadoc 的那个.例如,对于 Firebase 实时数据库,您可以使用firebase-database-9.2.0".
- 在上下文菜单中,单击底部的库属性.
- 在库属性窗口中,有一个带有 + 号的按钮.单击那个.这使您可以将 javadoc 路径附加到该库中的类.
- 从上方导航/粘贴您的 javadoc 路径到对话框中.
- 在下一个对话框中,告诉它JavaDocs".
现在,当您为该库中的类调用 javadoc 时,您会看到它.但是,您必须为每个需要 javadoc 的库执行此操作.
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.
如果您由于某种原因没有安装本地 javadoc,您可以附加 javadoc 的远程 url.为此,请使用下方带有小地球的加号按钮,然后粘贴 javadoc url.对于 Firebase,这是 https://firebase.google.com/docs/reference/android对于 Play 服务,这是 https://developers.google.com/android/reference/
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/
完成所有这些手动工作并不好,但至少它可以让您在 IDE 中获得 javadoc.
It's not great to do all this manual work, but at least it gets you javadoc in your IDE.
如果你想编写一个脚本来为你使用的所有东西附加这个,请知道这个过程基本上只是修改 .idea/libraries 下的文件.您可以很容易地观察到在 IDE 中进行更改时被修改的 javadoc XML 元素,如果需要,您可以自己编写/编辑更改.
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.
这篇关于如何让 Google Play 服务 API 和 Firebase API 的 API javadoc 显示在 Android Studio 中,而不是没有文档的反编译类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!