剑痴乎

剑痴乎
代码为剑,如痴如醉
  1. 首页
  2. WebRTC
  3. 正文

WebRTC 安卓Native code编译问题

2020年3月24日 3649点热度 5人点赞 5条评论

开此文章用于记录自己编译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
# 回车,默认选择

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可
标签: WebRTC
最后更新:2020年5月22日

Jeff

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

打赏 点赞
< 上一篇
下一篇 >

文章评论

  • ambush

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

    2020年4月25日
    回复
    • Jeff

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

      2020年4月25日
      回复
      • Jeff

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

        2020年4月25日
        回复
  • jingju

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

    2020年12月14日
    回复
  • vivi

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

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

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

    这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

    版权声明

    为支持原创,创作更好的文章,未经许可,禁止任何形式的转载与抄袭,如需转载请邮件私信!本人保留所有法定权利。违者必究!

    文章目录
    • 问题0x01
    • 问题0x02
    • 问题0x03
    最近评论
    ztt 发布于 3 周前(04月05日) 你好,想看里面的视频和图片为什么没有显示呢?需要下flash吗还是什么。
    huowa222 发布于 4 周前(03月26日) 同问
    邱国禄 发布于 2 个月前(02月17日) Receive Delta以0.25ms为单位,reference time以64ms为单位,kDe...
    啊非 发布于 4 个月前(12月30日) 大神,请教一个问题: constexpr int kBaseScaleFactor = Tran...
    啊非 发布于 4 个月前(12月30日) reference time:3字节,表示参考时间,以64ms为单位,但是 代码里面是 Trans...
    相关文章
    • WebRTC资讯:H265支持进展
    • WebRTC研究:Audio level
    • Mac平台WebRTC编译
    • WebRTC研究:RTP时间戳的产生
    • WebRTC研究:统计参数之丢包率

    COPYRIGHT © 2024 jianchihu.net. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang