This is the third day of my participation in the More text Challenge. For details, see more text Challenge
preface
In the previous article, AOSP source Code Environment Building we have down the entire AOSP source code to our hard drive. Next we will Read The Fucking Source Code!
The preparatory work
The principle of
Idegen is a tool designed specifically for debugging source code in an IDE environment, so we need the following three steps to import the project into AS
- Get to idegen. The jar
- Obtain idegen.sh and run the command to generate android.ipr/android.iml
- Android sutdio Select Android. ipr
If you don’t want to compile the entire AOSP source code, you can refer to the AOSP frameworks source environment for idegen.jar and idegen.sh
Let’s do the full version
cd~ /aosp // The specific source root // used to initialize environment variablessourceBuild/envsetup. Sh / / generated file out/host/Linux x86 / framework/idegen jar attention could be a problem to under bash ZSH MMM development/tools/idegen / / / source root generated file android. Ipr (engineering related Settings), android. On iml (module related configuration.)/development/tools/idegen/idegen sh / / to read and write, otherwise, Iml sudo chmod 777 android.iml sudo chmod 777 android.iprCopy the code
M /mm/ MMM /make Reference to the Android source code compilation command m/mm/ MMM /make analysis
todo
Blog.csdn.net/mcryeasy/ar…
How to read wiki.lineageos.org/import-andr…
Import the source code
Open Android Studio, click File -> Open, and select the previously generated android.ipr File. This process is time-consuming
Speed up the configuration file before loading
By default, all files except the following 14 folders will result in the AS project. This is obviously very large, so we can optionally import AS follows:
<excludeFolder url="file://$MODULE_DIR$/.repo"/>
<excludeFolder url="file://$MODULE_DIR$/external/bluetooth"/>
<excludeFolder url="file://$MODULE_DIR$/frameworks/base/docs"/>
<excludeFolder url="file://$MODULE_DIR$/out/host"/>
<excludeFolder url="file://$MODULE_DIR$/prebuilt"/>
Copy the code
Speed up after loading
If you have imported all your projects into Android Studio and want to remove them, an easy way to do this is to go to Project Structure -> Modules. Run the excluede option in red, which represents the deleted directory, as shown below:
Configure the source to jump correctly
Configuring the JDK/SDK here is designed to solve the problem of correctly jumping to the target source code, not the CODE in the SDK, during the process of analyzing and debugging the source code. Click “Project Structure” under “File” menu.
The new JDK (No Libraries)
- To create JDK(No Libraries), select the same path as the previous one
- Delete ClassPath and SourcePath from JDK(No Libraries)
Configure the SDK
Project Structure -> SDKs, select Android API 28 Platform, and select Java SDK as JDK(No Libraries)
Select the SDK
Depend on
Project Structure -> Modules -> android -> Dependencies: Remove all dependencies outside of the Android API 25 Platform, then click on the green + sign shown in the following image to select frameworks or directories and add frameworks or any other source directories you’re interested in.
debugging
The previous has set up the Android source debugging environment, the next can be online debugging source. First, you’ll need a phone with a debug version that turns on developer options to allow USB debugging.
The core frameworks service runs in the system_server process, named system_process on the debugger, and attaches to the target process we want to debug. The same is true for other app processes.
reference
Building the AndroidStudio source development environment