首页 / ANDROID / Android源码编译
Android源码编译
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Android源码编译,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含7452字,纯文字阅读大概需要11分钟。
内容图文
常用编译命令
在Android源代码目录下的build目录下,有个脚本文件envsetup.sh,执行这个脚本文件后,就可以获得一些有用的工具
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch: lunch <product_name>-<build_variant>
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory, but not their dependencies.
- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
To limit the modules being built use the syntax: mmm dir/:target1,target2.
- mma: Builds all of the modules in the current directory, and their dependencies.
- mmma: Builds all of the modules in the supplied directories, and their dependencies.
- cgrep: Greps on all local C/C++ files.
- ggrep: Greps on all local Gradle files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- sgrep: Greps on all local source files.
- godir: Go to the directory containing a file.
交叉编译:
参考
- mmm not found
使用m、mm、mmm命令之前要在android源码目录下执行命令
.?build/envsetup.sh??
- 解压android源码
tar xzf android-xxx.tar.gz
- linux解压
tar xzf linux-3.0.xx.tgz
cd linux-3.0.xx
cp tiny4412_android_defconfig .config
make zImage
- 编译
cd android-5.xx/
. setenv
lunch
chose full_tiny4412-eng
make
- 源码
官方源码
下载源码
- git 下载
- openjdk安装sudo apt install openjdk-7-jdk
对应版本如下
Android版本 | 编译要求的JDK版本 |
---|---|
AOSP的Android主线 | OpenJDK 8 |
Android 5.x至android 6.0 | OpenJDK 7 |
Android 2.3.x至Android 4.4.x | Oracle JDK 6 |
Android 1.5至Android 2.2.x | Oracle JDK 5 |
java版本切换
sudo update-alternative --config java
sudo update-alternative --config javac
- repo
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
或者使用:
repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest
如果提示无法连接到 gerrit.googlesource.com,那么我们只需要编辑 ~/bin/repo文件,找到REPO_URL这一行,然后将其内容修改为:
REPO_URL = ‘https://gerrit-google.tuna.tsinghua.edu.cn/git-repo’
初始化repo
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1
- 环境配置
需要安装(16.04)
sudo apt-get install git-core gnupg flex bison gperf build-essential
zip curl 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
碰到的错误
- unable to create file tests/P_str_escape/str\escape.rs (Invalid argument)
Log 打印:
error: unable to create file tests/P_str_escape/str\\escape.rs (Invalid argument)
Checking out files: 100% (463/463), done.
Traceback (most recent call last):
File "/mnt/e/ruin/sources/android/.repo/repo/main.py", line 531, in <module>
_Main(sys.argv[1:])
File "/mnt/e/ruin/sources/android/.repo/repo/main.py", line 507, in _Main
result = repo._Run(argv) or 0
File "/mnt/e/ruin/sources/android/.repo/repo/main.py", line 180, in _Run
result = cmd.Execute(copts, cargs)
File "/mnt/e/ruin/sources/android/.repo/repo/subcmds/sync.py", line 821, in Execute
project.Sync_LocalHalf(syncbuf, force_sync=opt.force_sync)
File "/mnt/e/ruin/sources/android/.repo/repo/project.py", line 1327, in Sync_LocalHalf
self._InitWorkTree(force_sync=force_sync)
File "/mnt/e/ruin/sources/android/.repo/repo/project.py", line 2486, in _InitWorkTree
raise GitError("cannot initialize work tree")
error.GitError: cannot initialize work tree
解决方案 :
参考1
参考2
尝试手动创建tests/P_str_escape/str\escape.rs
实际要创建的文件并不是tests/P_str_escape/str\escape.rs
而是tests/P_str_escape/str/escape.rs
<your_path>\frameworks\compile\slang\tests\P_str_escape 这一级目录已经存在了,只需要创建str 目录,并在str 目录中创建 escape.rs 文件(文件内容为空)。
再次repo --trace sync
可以下载到完整的Android源代码了。
在win10bash上好像无解
- libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
Log打印
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/bin/ld: error: out/host/linux-x86/obj32/SHARED_LIBRARIES/libnativehelper_intermediates/JniInvocation.o: unsupported reloc 43 against global symbol JniInvocation::jni_invocation_
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/include/c++/4.6/bits/basic_string.h:270: error: unsupported reloc 43
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/include/c++/4.6/bits/basic_string.h:270: error: unsupported reloc 43
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/include/c++/4.6/bits/basic_string.h:235: error: unsupported reloc 43
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/include/c++/4.6/bits/basic_string.h:235: error: unsupported reloc 43
libnativehelper/JNIHelp.cpp:310: error: unsupported reloc 43
libnativehelper/JNIHelp.cpp:311: error: unsupported reloc 43
libnativehelper/JNIHelp.cpp:332: error: unsupported reloc 43
It works to me:
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
3 . 参考
错误描述:
/bin/bash: xmllint: command not found
sudo apt-get install libxml2-utils
4 .
Install: out/target/product/tiny4412/data/nativebenchmark/binderAddInts
target Dex: Bluetooth
out/target/common/obj/PACKAGING/public_api.txt:20: error 5: Added public field android.Manifest.permission.BACKUP
out/target/common/obj/PACKAGING/public_api.txt:81: error 5: Added public field android.Manifest.permission.INVOKE_CARRIER_SETUP
out/target/common/obj/PACKAGING/public_api.txt:105: error 5: Added public field android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
out/target/common/obj/PACKAGING/public_api.txt:115: error 5: Added public field android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
build/core/tasks/apicheck.mk:57: recipe for target 'out/target/common/obj/PACKAGING/checkapi-current-timestamp' failed
make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs....
Error: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar: unknown package name of class file com/slsi/sec/android/HdmiService.class
Preparing output jar [/home/rain/workspace/android/source/android-5.0.2/out/target/common/obj/APPS/Telecom_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/rain/workspace/android/source/android-5.0.2/out/target/common/obj/APPS/Telecom_intermediates/classes.jar]
最后终于编译成功
内容总结
以上是互联网集市为您收集整理的Android源码编译全部内容,希望文章能够帮你解决Android源码编译所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。