Android Studio View Android internal hidden source code

Android Studio View Android internal hidden source code

96 
zhang_pan 
2018.04.10 21:27   Words 546   Reads 313 Comments 2

problem finding

When I checked the source code of AlertDialog today, I saw AlertController, and found that all the codes about this part are red. It turns out that the AlertController class is under the package com.android.internal.app, look at the package name internal (internal), which means this Part of the code is not open to the public due to factors such as security and stability of Google.

problem solving

In fact, this problem has always existed, but I didn't check these hidden source codes carefully before, and I just passed by! Then there is a problem, it must be solved, how to solve this? In fact, there are still solutions:
the first solution:
http://androidxref.com/  The source code of each version of Android (including the C layer) is available under this URL, which are all online and easy to view:

1.png

Feel free to click on a version and go, we enter the class we want to find:

2.png

We find this class, click it to view the source code of this class, which is more convenient.

The second solution:
GitHub has removed the @hide annotation in Android.jar, the source code here is relatively complete (note that it can only be relatively complete, there is still no code for the C layer, because it is only a jar package)
Address:  https ://github.com/anggrayudi/android-hidden-api

  1. Close Android Studio
  2. Download the Android.jar corresponding to the API version
  3. Replace SDK/platforms/android-versions/Android.jar
  4. Reopen Android Stuido to view

At this time, we can view these hidden APIs at will in Android Studio.

Summarize

Both methods are actually possible, and both methods have their own advantages and disadvantages. The first method is simple, including the C-layer source code, but it is not very convenient to view the code and jump; the second method is more suitable for viewing the Java source code, and the jump is convenient, but there is no C-layer source code. Generally, when I use it, I use the two together, and the efficiency will be better!

Friends of Jane who like this blog, please come to a wave of likes. Every time you pay attention, it will become the driving force for me to move forward. Thank you!

Take a walk with a small gift, come to Jianshu and follow me


Reprinted from: https://www.jianshu.com/p/7c1aca9f001b

Appreciate the support

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325561709&siteId=291194637