此文章主要记录git/gerrit配置;MTK2601 AOSP Android5.1的编译以及应用开发。
1、git/Gerrit:
vim ~/.gitconfig
[User]
email =【你的邮箱,通常是公司企业邮箱】
name = 【gerrit服务器账户名】
[color]
ui = auto
diff = auto
[core]
editor = vim
# 说明:review的配置和代码树的使用有关联,所以一定保证正确
[review "Gerrit服务器地址,例如110.110.110.110:9090"]
username =【Gerrit账户名】
#然后ssh-keygen生成的publickey复制到gerrit服务器
#next:
vim ~/.ssh/config
Host 【gerrit服务器IP】
KexAlgorithms +diffie-hellman-group1-sha1
Port 29418
User 【Gerrit账户名】
2、repo以及代码树编译:
repo文件根据Google官方提供的大可自己修改。
从头获取整个代码树:
repo init -u ssh://IP地址:29418/repo/manifests -b android_watch_master
repo sync
等待代码下载完毕。
编译Android源码:
1)Android5.1需要安装openjdk7:
sudo add-apt-repositoryppa:openjdk-r/ppa
sudo apt-getupdate
sudo apt-getinstall openjdk-7-jdk
切换Java环境到jdk7.
其次,安装依赖:
---------------------------------------------------------------------------------------------------------------
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install lib32z-dev ccache
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
---------------------------------------------------------------------------------------------------------------
2)在 .bashrc文件末尾添加:export USE_CCACHE = 1
为了提高编译效率,设置编译器高速缓存:
prebuilts/misc/linux-x86/ccache/ccache-M50G
编译步骤:
... 自己的配置 ...
source build/envstep.sh
lunch
make -j8
... 编译成功 ...
3)如果有一下错误:
{
/home/elinksoft/code/8163/alps/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/../lib/gcc/x86_64-linux/4.6/../../../../x86_64-linux/bin/ld: error: out/host/linux-x86/obj32/STATIC_LIBRARIES/libcompiler_rt_intermediates/libcompiler_rt.a(eprintf.o): unsupported reloc 43 against global symbol stderr
external/compiler-rt/lib/builtins/eprintf.c:32: error: unsupported reloc 43
collect2: ld returned 1 exit status
build/core/host_shared_library_internal.mk:44: recipe for target 'out/host/linux-x86/obj32/lib/libcompiler_rt.so' failed
make: *** [out/host/linux-x86/obj32/lib/libcompiler_rt.so] Error 1
make: *** Waiting for unfinished jobs....
host C++: libnativehelper_32 <= libnativehelper/JNIHelp.cpp
make: *** wait: No child processes. Stop.
}
解决:
{
in file /art/build/Android.common_build.mk, find out:
# Host.
ART_HOST_CLANG := false
ifneq ($(WITHOUT_HOST_CLANG),true)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
change to :
# Host.
ART_HOST_CLANG := false
ifeq ($(WITHOUT_HOST_CLANG),false)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
If it still not works,try this in your android root path:
cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld
}
4、System App
1)常用命令
croot、jgrep、cgrep、resgrep
mm -B
repo sync . -cj4
repo upload .
repo branch
git reset
repo abandon 0722
repo sync . -c
repo start 0722 --all
2)提交代码树review发现问题或者测试出现问题:
Cherry Pick到本地,gerrit上有命令可以直接复制使用;
修改后git commit --amend
repo upload .
3)导入aosp所有代码到Android Studio:
前提是代码树已经build成功;在代码树根目录下执行:
mmm development/tools/idegen/ #这行命令的意思是编译idegen这个模块项目,然后生成idegen.jar文件
development/tools/idegen/idegen.sh #这行命令的意思是在根目录生成对应的android.ipr、android.iml IEDA工程配置文件
有了如上的这些操作以后,我们打开Android Studio,然后选择打开一个现有的Android Studio项目,然后选择打开源码根目录下的android.ipr文件
4)编写Android.mk文件
make file比较复杂无法一一详细说明,可以查阅其他资料;Android.mk编写完成后,在对应目录下执行mm -B即可模块编译。
配合第(5)步的说明即可轻松开发app
5)系统工程无法在AS Build 通过,但是可以链接文件到AS:
使用 ln -s 把文件链接到Android Studio工程目录下(model/src/main/java等目录)
最后就是adb常用命令,比较多就不写了。
6)aosp下查找文件内容常用命令
mv * .[^.]* repo_root/
grep BOOT_COMPLETED . -rsn|grep -v xml|grep -v txt|grep -v html
find -name "filename"
find . -name 'gradle-wrapper.properties' -exec grep "bin" {} +;
sed -i s/MySystemService/System/g `grep MySystemService -rl ./`
adb shell pm list packages;adb shell pm path+ 包名,例如:adb shell pm path com.cmsz.account;adb pull+安装包路径
备注:博客收藏http://blog.csdn.net/wdaming1986