JCHub

  • Home
  • Category
    • A/V
    • WebRTC
    • Beauty of Programming
    • Linux
    • Windows
    • Moments of Life
    • Campus Life
  • Reference
    • API Reference
    • Utilities
    • AV Test
    • Doc
  • Message Board
  • About
JCHub
Code as My Sword, Lost in Obsession
  1. Main page
  2. WebRTC
  3. Main content

WebRTC 安卓Native code编译问题

2020年3月24日 4292hotness 5likes 5comments

开此文章用于记录自己编译WebRTC安卓Native code遇到的问题。

问题0x01

错误提示如下:

1
2
3
4
5
6
7
8
9
10
11
12
Traceback (most recent call last):
  File "./build_aar.py", line 234, in <module>
    sys.exit(main())
  File "./build_aar.py", line 230, in main
    args.build_dir, args.extra_gn_switches, args.extra_ninja_switches)
  File "./build_aar.py", line 214, in BuildAar
    CollectCommon(aar_file, build_dir, archs[0])
  File "./build_aar.py", line 179, in CollectCommon
    aar_file.write(MANIFEST_FILE, 'AndroidManifest.xml')
  File "/usr/lib/python2.7/zipfile.py", line 1146, in write
    st = os.stat(filename)
OSError: [Errno 2] No such file or directory: 'sdk/android/AndroidManifest.xml'

这个是在我执行build_aar.py --build-dir out --arch "armeabi-v7a" "arm64-v8a"命令编译生成aar文件遇到的。看了下目录,
sdk/android/AndroidManifest.xml是存在的。后来发现是路径问题。得切到WebRTC源码/src目录下执行:

1
./tools_webrtc/android/build_aar.py --build-dir out --arch "armeabi-v7a" "arm64-v8a"

而我原来是在/tools_webrtc/android/里直接执行build_aar.py。

问题0x02

编译支持H264软编软解报的问题,之前编译都没问题,编译错误打印如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
ERROR:root:Missing licenses for following third_party targets: openh264, ffmpeg
Traceback (most recent call last):
  File "./tools_webrtc/android/build_aar.py", line 234, in <module>
    sys.exit(main())
  File "./tools_webrtc/android/build_aar.py", line 230, in main
    args.build_dir, args.extra_gn_switches, args.extra_ninja_switches)
  File "./tools_webrtc/android/build_aar.py", line 219, in BuildAar
    GenerateLicenses(license_dir, build_dir, archs)
  File "./tools_webrtc/android/build_aar.py", line 197, in GenerateLicenses
    builder.GenerateLicenseText(output_dir)
  File "/home/jeff/webrtc/src/tools_webrtc/android/../libs/generate_licenses.py", line 204, in GenerateLicenseText
    raise Exception(error_msg)
Exception: Missing licenses for following third_party targets: openh264, ffmpeg

问题出在generate_licenses.py里,WebRTC安卓H264启用openh264编码,ffmepg解码,很多地方得自己手动加进去,generate_licenses.py里openh264以及ffmpeg的license路径我之前没加,导致编译报如上错误,按如下修改即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py
index b8894ed39b..fec153c2bb 100755
--- a/tools_webrtc/libs/generate_licenses.py
+++ b/tools_webrtc/libs/generate_licenses.py
@@ -69,6 +69,8 @@ LIB_TO_LICENSES_DICT = {
     'g722': ['modules/third_party/g722/LICENSE'],
     'fft4g': ['common_audio/third_party/fft4g/LICENSE'],
     'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
+    'openh264':['third_party/openh264/src/LICENSE'],
+    'ffmpeg':['third_party/ffmpeg/LICENSE.md'],
     # TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
     # For some reason it is listed as so in _GetThirdPartyLibraries.

问题0x03

切换WebRTC到去年11月某个日期版本,同时也切换depot_toos到对应日期,执行gclient sync,然后重新执行build_aar.py编译出现如下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[2832/3278] ACTION //third_party/auto:auto_common_java__compile_java(//build/toolchain/android:android_clang_arm)
FAILED: gen/third_party/auto/auto_common_java.javac.jar gen/third_party/auto/auto_common_java.javac.jar.info
python ../../build/android/gyp/javac.py --depfile=gen/third_party/auto/auto_common_java__compile_java.d --generated-dir=gen/third_party/auto/auto_common_java/generated_java --jar-path=gen/third_party/auto/auto_common_java.javac.jar --java-srcjars=\[\] --java-version=1.8 --full-classpath=@FileArg\(gen/third_party/auto/auto_common_java.build_config:deps_info:javac_full_classpath\) --interface-classpath=@FileArg\(gen/third_party/auto/auto_common_java.build_config:deps_info:javac_full_interface_classpath\) --processorpath=@FileArg\(gen/third_party/auto/auto_common_java.build_config:javac:processor_classpath\) --processors=@FileArg\(gen/third_party/auto/auto_common_java.build_config:javac:processor_classes\) --errorprone-path bin/errorprone @gen/third_party/auto/auto_common_java.sources
Traceback (most recent call last):
  File "../../build/android/gyp/javac.py", line 608, in <module>
    sys.exit(main(sys.argv[1:]))
  File "../../build/android/gyp/javac.py", line 603, in main
    output_paths=output_paths)
  File "/home/jeff/webrtc/src/build/android/gyp/util/build_utils.py", line 674, in CallAndWriteDepfileIfStale
    track_subpaths_whitelist=track_subpaths_whitelist)
  File "/home/jeff/webrtc/src/build/android/gyp/util/md5_check.py", line 99, in CallAndRecordIfStale
    function(*args)
  File "../../build/android/gyp/javac.py", line 598, in <lambda>
    lambda: _OnStaleMd5(options, javac_cmd, java_files, classpath),
  File "../../build/android/gyp/javac.py", line 356, in _OnStaleMd5
    stderr_filter=ProcessJavacOutput)
  File "/home/jeff/webrtc/src/build/android/gyp/util/build_utils.py", line 231, in CheckOutput
    raise CalledProcessError(cwd, args, stdout + stderr)
util.build_utils.CalledProcessError: Command failed: ( cd /home/jeff/webrtc/src/out/armeabi-v7a; bin/errorprone -g -encoding UTF-8 -sourcepath : -XepDisableAllChecks -source 1.8 -target 1.8 -XDignore.symbol.file -d /tmp/tmpO3NFM3/classes -classpath lib.java/third_party/guava/guava.interface.jar @/tmp/tmpO3NFM3/files_list.txt )
-Xbootclasspath/p is no longer a supported option.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

说无法创建Java Virtual Machine,解决方法,下面两个方法都试了,然后编译通过。也不知道哪个起作用,懒得折腾去验证了:

1
2
3
4
sudo apt-get purge openjdk-8-jdk
sudo apt-get install openjdk-11-jre
sudo apt-get install openjdk-8-jre
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64

1
2
3
4
5
6
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
 
sudo update-alternatives --config java
# 回车,默认选择

This article is licensed with Creative Commons Attribution-NonCommercial-No Derivatives 4.0 International License
Tag: WebRTC
Last updated:2020年5月22日

Jeff

管理员——代码为剑,如痴如醉

Tip the author Like
< Last article
Next article >

Comments

  • ambush

    您好,请问openH264和ffmpeg的Licence是需要自己添加进去呢?还是webrtc source里就有呢?如果是需要自己加进去,请问在哪里获取?

    2020年4月25日
    Reply
    • Jeff

      @ambush webrtc source里本来就有了,你在generate_licenses.py把它们路径加进去就可以了

      2020年4月25日
      Reply
      • Jeff

        @Jeff 具体路径你看下我文章的git diff描述

        2020年4月25日
        Reply
  • jingju

    大神,请教,能不能给个靠谱的webrtc android 编译需要修改哪些东西的方案

    2020年12月14日
    Reply
  • vivi

    sudo update-alternatives --config java
    # 回车,默认选择

    这个地方是错误的 应该选择java8就可以了

    2021年4月7日
    Reply
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    Cancel

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    文章目录
    • 问题0x01
    • 问题0x02
    • 问题0x03
    相关文章
    • 浅谈基于SFU实现一对一效果
    • WebRTC资讯:H265支持进展
    • Protected: WebRTC硬件编解码器出错无缝切换软编软解
    • WebRTC研究:Audio level
    • Mac平台WebRTC编译

    COPYRIGHT © 2026 jianchihu.net. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang