Introduction to Android code download, compilation and debugging

Table of contents

One: Environment preparation - install repo, git

Two: Environment preparation - configure git

Three: Environment preparation - configuration key

Four: Add the key to the SSH Public Kes corresponding to gerrit

Five: Code download

Six: Code Compilation

Seven: Android common shortcut commands

Eight: It is recommended to look at the log tool


One:  Environment preparation - install repo, git

1 : Repo is a tool developed based on git , which is convenient for git resource management, so we need to install git before installing repo

    sudo apt-get install git

2 : Then create a new bin directory in the user's home directory

    mkdir ~/ bin

3 : Add the bin directory to the system path , open ~/.bashrc , and add the following content

    export  PATH=~/bin:$PATH

Execute source .bashrc after saving

4 : Download repo

    curl http://gerrit.googlesource.com/git-repo/repo > ~/bin/repo

Two:  Environment preparation - configure git

 git config --global user.name jiayou.gan

git config --global user.email [email protected]

Three: Environment preparation - configuration key

1: Generate ssh key file, execute ssh-keygen -t rsa -C "[email protected]";

2: Then you will be asked to enter the password twice, just press Enter, and the key fingerprint and key's randomart will appear at the end, indicating that the creation is successful.

3: At this time, execute la in the main directory, and you can see the generated .ssh directory

Four: Add the key to the SSH Public Kes corresponding to gerrit

ssh$ cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDcC+GbffKN7ANMIL9f3FJpy+lCgovFhbfhh6Hy55nRkUu74pGatUYNVZZxa0gURbrpihAnu81DuOo+YSN/z0rwuQQLouXTmIcXcv538f2v04+Ww2BmR7DOS2xSQeTjwc0UGz31LAP/nHLJdQPds2FJgObcIqkf0gz9UHgQc4sV6J/pMdfVhIi1VZSSVw0T5+NtucBGYIUFG0nFwAnk5m5IvhK4FNaD9CTwCg8nE3PtwhAhDxXgtt2m1TbD9e8B6wkfXfyhRQ0WuPVd7SGhgjmBkXxNZn1b/+Eel+um5K9rMln2mvnhUd5p7mWtYxgfEo6SK0jSUOtCtJACYfTCixat [email protected]

Copy these contents and paste them into the corresponding SSH Public Keys on gerrit

Five: Code download

After the above configuration, you can download the code at this time

repo init -u http://username@XXX

If init reports an error as follows:

sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).

Then execute the following command in the terminal and then re-init

    eval "$(ssh-agent -s)"
    ssh-add

repo sync -c -d  --no-tags

Six: Code Compilation

source build/envsetup.sh

lunch and select the corresponding serial number according to the project

make -j32

Seven: Android common shortcut commands

Check if the device is connected to the computer: adb devices

Catch log : adb logcat (-b all) >log.txt

Dynamic filter log : adb logcat (-b all)| grep " keyword " – i ( ignore case ) –-color ( highlight )

Filter two or more keyword logs : adb logcat (-b all)| grep – iE " Keyword 1| Keyword 2"

Find the name and location of the installation package based on keywords: adb shell pm list packages –f| grep “ keyword

View the current app package name and activity name: adb shell dumpsys activity| grep Resumed

Check phone resolution: adb shell wm size

Eight: It is recommended to look at the log tool

mulled wine
Installation method sudo apt-get install glogg

Guess you like

Origin blog.csdn.net/weixin_41028555/article/details/130378897