1. Download and install Docker Desktop www.docker.com/

2. Set Docker Resources, as shown in the figure, according to the performance of their own devices

Build an Ubuntu environment

  • Create a folder, \my_android_linux

  • Create a file named Dockerfile

  • Edit the Dockerfile file:

    #Dockerfile # Linux source Linux version ubuntu:18.04 FROM Ubuntu :18.04 #update apt-get source RUN apt-get update  CMD ["sh"]Copy the code

4. Start PowerShell in \my_ Android_linux

Docker build -t my_android_linux. It automatically scans the Dockerfile in the current folder and then performs the configuration in the Dockerfile file

Execute command: Docker run -t -i -v F:\ docker \my_android_linux\win_share_files:/win_share_files my_android_linux bash Map (or mount) the F: Docker my_android_linux win_share_files folder to the Win_share_files folder in Linux. The folder names left and right of “:” can be different

After executing the above two commands, you will automatically enter the Linux environment. So we’ve basically set up a Linux environment

5. Docker image created by us can also be seen in Docker Desktop

6, enter the Linux system, do the preparation work of synchronizing the source code to the local and compiling:

Preparations:

  • Git installation

    #:apt-get install git
    #:git config --global user.name "Your Name"
    #:git config --global user.email "[email protected]"
    Copy the code
  • Download and install the REPO

    #:mkdir ~/bin
    #:PATH=~/bin:$PATH
    #:curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    #:chmod a+x ~/bin/repo
    Copy the code
  • Download and install OpenJDK

    #:apt-get install openjdk-8-jre
    Copy the code
  • Install the libraries required for compilation

    #:apt-get install gnupg flex bison gperf build-essential zip zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
    Copy the code

7, synchronous source code, I use a mirror of the University of Science and Technology

# : repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest - b android - 8.1.0 _r81 - repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo note: - repo-url=https://mirrors.tuna.tsinghua.edu.cn/ It means to switch the repo-URL to the mirror of Tsinghua, because repo init will update the repo file, the built-in URL of the repo file is the URL of Google, access timeout. Of course, you can simply change the built-in URL to #:repo syncCopy the code

8. Compilation:

#:source build/envsetup.sh
#:lunch
#:make -j8
Copy the code

9. Generate an Android. ipr file

# # : MMM development/tools/idegen: / development/tools/idegen/idegen sh will be in the root directory, generate android. Ipr file, the file can use the android open Studio, Open you can see a variety of source codeCopy the code

10 and the END

Summary of problems encountered:

1. Map (or mount)Windows directories to Linux

Use the docker run -t -i -v F:\ docker \my_android_linux\android_source:/win_share_files my_android_linux bash command to map the file while runningCopy the code

2. In Linux, an error occurs when repo init and repo sync are performed in the mapped directory, as shown in the following figure

Cause: The mapping between two operating system directories is not resolved. You can only create a directory in Linux, download and compile the source code, and copy it to the mapping directory

3. How to copy files between two operating systems:

Run the docker cp command

Docker cp.\ jdK-8u281-linux-x64.tar. gz 706ddb8b7bca:/java_8/ Copy the jdK-8U281-linux-x64.tar. gz file to the CONTAINER In the Linux /java_8/ directory whose ID is 706ddb8b7bcaCopy the code

4, report GC overhead limit exceeded error

Solution:

#:export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
#:jack-admin kill-server
#:jack-admin start-server
Copy the code

5. Role problems during compilation:

#:export USER=$root
Copy the code

6. When the HTTPS image is used, urlopen error unknown URL type: HTTPS is reported

Solution:

Recompile Python3.6+ with the --with-ssl parameter #./configure --prefix=/usr/local/python37 --with-sslCopy the code

Reference:

Install repo: source. Android. Google. Cn/setup/devel…

Update code: the source. The android. Google. Cn/setup/build…

Ubuntu apt – get domestic image source: developer.aliyun.com/mirror/ubun…

Ubuntu apt-get Ubuntu apt-get

Docker folder mapping in Windows: blog.csdn.net/m0_38044453…

Under Windows using the Docker compiled Android source code: cloud.tencent.com/developer/a…

Tsinghua university, the Android open source image: mirrors.tuna.tsinghua.edu.cn/help/AOSP/

Ubuntu installation Python3.6+:www.jianshu.com/p/940b774a0…

Windows installation docker, build Linux:zhuanlan.zhihu.com/p/70870453

The Android build number: source. Android. Google. Cn/setup/start…

Use AndroidStudio view and debug Android source: blog.csdn.net/cfy137000/a…

Stood: download the Android source code from the source image xusiwei. Making. IO/post / 2020/0…

Structures, compile environment: source. Android. Google. Cn/source/init…

Android ipr and on iml file: www.jianshu.com/p/6b60e3cb5…

Error urlopen error unknown URL type: HTTPS blog.csdn.net/qq_38189484…