Ubuntu 1804 编译 Android Cronet 时安装依赖项

Android Cronet 需要在 linux 平台下编译,因为部分工具只能在 Ubuntu 上执行(Chromium 项目大部分开发工作是在 Ubuntu 上完成的),因此优先选择 Ubuntu 系统。

编译 Cronet 库需要安装系统依赖以及安卓的特殊依赖,在 chromium 项目中都有专门的脚本去执行依赖的安装,进入已下载好源码的 chromium/src 目录,执行如下脚本:

./build/install-build-deps.sh   // 安装系统依赖

sudo update-java-alternatives -s java-1.8.0-openjdk-amd64  // 升级 java-jdk 到 1.8.0,如果未安装 java-jdk,则需单独安装好

./build/install-build-deps-android.sh     // 安装特殊的安卓依赖

没有安装安卓特殊依赖会出现如下错误, No such file or directory:

ninja: Entering directory `out/test-Cronet/'
[99/6835] ACTION //base:android_runtime_jni_headers__jni_Runnable(//build/toolchain/android:android_clang_arm)
FAILED: gen/base/android_runtime_jni_headers/base/jni/Runnable_jni.h 
python ../../base/android/jni_generator/jni_generator.py --jar_file ../../third_party/android_sdk/public/platforms/android-28/android.jar --input_file java/lang/Runnable.class --ptr_type=long --output_dir gen/base/android_runtime_jni_headers/base/jni --includes ../../../../../../../base/android/jni_generator/jni_generator_helper.h
Traceback (most recent call last):
  File "../../base/android/jni_generator/jni_generator.py", line 1628, in 
    sys.exit(main(sys.argv))
  File "../../base/android/jni_generator/jni_generator.py", line 1624, in main
    GenerateJNIHeader(input_file, output_file, options)
  File "../../base/android/jni_generator/jni_generator.py", line 1532, in GenerateJNIHeader
    jni_from_javap = JNIFromJavaP.CreateFromClass(input_file, options)
  File "../../base/android/jni_generator/jni_generator.py", line 847, in CreateFromClass
    stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
[101/6835] CC obj/third_party/apache-portable-runtime/apr/rand.o
ninja: build stopped: subcommand failed.

其他错误

  • src/third_party/android_ndk/sources/cxx-stl/llvm-libc++/ 目录被删除
    问题发现:在精简 chromium 仓库源码时,我删除了该目录,从下面的错误可以看到,
    有目标文件依赖该目下的库,即 libandroid_support.a 和 libunwind.a 。
    解决办法:从完整且版本匹配的 chromium 仓库拷贝该目录到对应位置。
python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/android_ndk/toolchains/arm-
linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf" --
nm="../../third_party/android_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-
androideabi-nm" --strip=../../buildtools/third_party/eu-strip/bin/eu-strip --sofile="./lib.unstripped/libnetty-
tcnative.so" --tocfile="./libnetty-tcnative.so.TOC" --output="./libnetty-tcnative.so" -- ../../third_party/llvm-
build/Release+Asserts/bin/clang++ -shared -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-
z,now -Wl,-z,defs -Wl,--as-needed --gcc-toolchain=../../third_party/android_ndk/toolchains/arm-linux-
androideabi-4.9/prebuilt/linux-x86_64 -fuse-ld=lld -Wl,--color-diagnostics -Wl,--no-rosegment -Wl,--exclude-
libs=libgcc.a -Wl,--exclude-libs=libvpx_assembly_arm.a --target=arm-linux-androideabi -Werror --
sysroot=../../third_party/android_ndk/platforms/android-16/arch-arm -nostdlib -Wl,--warn-shared-textrel -
L../../third_party/android_ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -o "./lib.unstripped/libnetty-
tcnative.so" -Wl,-soname="libnetty-tcnative.so" @"./libnetty-tcnative.so.rsp"
ld.lld: error: unable to find library -landroid_support
ld.lld: error: unable to find library -lunwind

FAILED: android_clang_x64/gen/base/android_runtime_jni_headers/base/jni/Runnable_jni.h

你可能感兴趣的:(cronet)