With the AOSP Source code, the next step is how to read it. I can read it directly in text, using Source Insight, and of course I choose Android Studio. Android Studio is a very powerful tool that I am familiar with. How to import the AOSP source code into Android Studio?
Install the Java
The newly installed Ubutun vm does not have Java at the beginning, so you need to install it first. If you run the Java command, the following error message is displayed:
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
Copy the code
Enter the above command to install, and then the code for the regrouping (more on regrouping and ungrouping in the next section) returns an error:
Your version is: openjdk version "10.0.1"2018-04-17 OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1) OpenJDK 64-bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1 10.0.1+10-Ubuntu- 3Ubuntu1, mixed mode). The required version is:"1.8.x"
Copy the code
The Java version must be 1.8.x.
sudo update-alternatives --config java
Copy the code
Output:
There are two candidates to replace Java (/usr/bin/java is provided). Choose the path priority status -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * 0 /usr/lib/jvm/java-11-openJDK-amd64/bin/java 1101 Automatic mode 1 /usr/lib/jvm/java-11-openJDk-amd64/bin/java 1101 Manual mode 2 /usr/lib/jvm/java-8-openJDK-amd64 /jre/bin/java 1081 Manual Mode To retain the current value [*], press < Enter >, or enter the selected number: 2Copy the code
expand
Oacle JDK, Oracle JDK, Oracle JDK, Oracle JDK, Oracle JDK, Oracle JDK
You asked for an OpenJDK based build but your version is
java version "1.8.0 comes with _181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode).
Copy the code
idegen.jar
In Ubuntu, go to the source code root directory and run the following command:
source build/envsetup.sh
mmm development/tools/idegen/
Copy the code
Error:
Command 'make' not found, but can be installed with:
sudo apt install make
sudo apt install make-guile
Copy the code
After the success of the command to install the make, run again MMM development/tools/idegen /, will be in the source directory out/host/Linux x86 / framework directory or become idegen. Jar file.
If the command MMM development/tools/idegen/has been an error, you can try the command make idegen rely on compilation.
Android. On iml and android. Ipr
Continue with the following command in the source directory:
development/tools/idegen/idegen.sh
Copy the code
Android. Iml and Android. Ipr files will be generated in the root directory. These two files are the project configuration files of Android Studio. Iml file, search for the excludeFolder file, and add the following code:
<excludeFolder url="file://$MODULE_DIR$/art" />
<excludeFolder url="file://$MODULE_DIR$/bionic" />
<excludeFolder url="file://$MODULE_DIR$/bootable" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/cts" />
<excludeFolder url="file://$MODULE_DIR$/dalvik" />
<excludeFolder url="file://$MODULE_DIR$/developers" />
<excludeFolder url="file://$MODULE_DIR$/development" />
<excludeFolder url="file://$MODULE_DIR$/device" />
<excludeFolder url="file://$MODULE_DIR$/docs" />
<excludeFolder url="file://$MODULE_DIR$/external" />
<excludeFolder url="file://$MODULE_DIR$/hardware" />
<excludeFolder url="file://$MODULE_DIR$/kernel" />
<excludeFolder url="file://$MODULE_DIR$/libcore" />
<excludeFolder url="file://$MODULE_DIR$/libnativehelper" />
<excludeFolder url="file://$MODULE_DIR$/out" />
<excludeFolder url="file://$MODULE_DIR$/pdk" />
<excludeFolder url="file://$MODULE_DIR$/platform_testing" />
<excludeFolder url="file://$MODULE_DIR$/prebuilts" />
<excludeFolder url="file://$MODULE_DIR$/sdk" />
<excludeFolder url="file://$MODULE_DIR$/system" />
<excludeFolder url="file://$MODULE_DIR$/test" />
<excludeFolder url="file://$MODULE_DIR$/toolchain" />
<excludeFolder url="file://$MODULE_DIR$/tools" />
<excludeFolder url="file://$MODULE_DIR$/.repo" />
Copy the code
Import the Android Studio
I copied the Android source code to my Mac, opened Android Studio, selected Open an Existing Android Studio Project, went to the source directory, and hit Android.ipr, Open, Wait about 6 minutes, import complete, Enjoy coding.
The problem
Android Studio keeps scanning files to Index.
1 Invalidate and restart does not work.
2 right click on the project > Open Module Setting > Modules > Go to the Gen folder and right-click Resources to finally say goodbye to annoying Scanning files to Index.
Series of blogs
VirtualBox install Ubuntu
AOSP source code download
AOSP source code BGF single
reference
Blog.csdn.net/HQZ82084401…
www.jianshu.com/p/fb16fa459…
Blog.csdn.net/shisanmei91…
The public,
My official account: Wu Xiaolong, welcome to exchange ~