【问题标题】:Unable to Compile WebRTC Library for Android无法为 Android 编译 WebRTC 库
【发布时间】:2020-08-02 16:55:45
【问题描述】:

我正在尝试编译 WebRTC Native Stack 以构建 libwebrtc.aar,但不幸的是无法理解出了什么问题。


系统信息:

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic
Java-Version:   OpenJDK-8-JDK
Python-Version: Python 2.7.17

我已按照official WebRTC Native Development for Android 中提供的完整步骤进行操作。这些步骤已在没有任何中断的情况下完成,并且每个步骤都需要时间来完成。然后,我必须安装构建源代码所需的所有依赖项。

./build/install-build-deps.sh

在编译代码之前,我还检查了特定的 git 分支以进入不同的可用 WebRTC 版本,使用此 git 命令列出所有分支。

git branch -r

我正在分享最新的 Git 分支:


我已经尝试了从branch-heads/60branch-heads/m79 的每个 git 分支,并且每个分支在使用编译命令时都有不同的问题。我已经尝试了这两个程序来构建库,例如:


1- 使用 AAR 构建工具 (./tools_webrtc/android/build_aar.py)

confu@ubuntu:~/webrtc_android/src$ tools_webrtc/android/build_aar.py
INFO:root:Building: armeabi-v7a
ERROR at //webrtc.gni:591:7: Can't load input file.
      absl_include_config,
      ^------------------
Unable to load:
  /home/confu/webrtc_android/src/third_party/abseil-cpp/BUILD.gn
I also checked in the secondary tree for:
  /home/confu/webrtc_android/src/build/secondary/third_party/abseil-cpp/BUILD.gn
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 210, in BuildAar
    extra_ninja_switches)
  File "tools_webrtc/android/build_aar.py", line 166, in Build
    _RunGN(gn_args_list)
  File "tools_webrtc/android/build_aar.py", line 93, in _RunGN
    subprocess.check_call(cmd)
  File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '/home/confu/webrtc_android/src/third_party/depot_tools/gn.py', 'gen', '/tmp/tmp1JDmHL/armeabi-v7a', '--args=arm_version=7 use_goma=false target_cpu="arm" is_component_build=false is_debug=false rtc_include_tests=false target_os="android"']' returned non-zero exit status 1

2- 使用手动编译 (gn gen out/Debug --args='target_os="android" target_cpu="arm"')

confu@ubuntu:~/webrtc_android/src$ gn gen out/Debug --args='target_os="android" target_cpu="arm64"'
ERROR at //BUILD.gn:648:20: Assignment had no effect.
      java_files = [
                   ^
You set the variable "java_files" here and it was unused before it went
out of scope.
See //BUILD.gn:647:5: whence it was called.
    junit_binary("android_junit_tests") {
    ^------------------------------------

【问题讨论】:

  • 据我所知,您正在获取特定的分支您是否尝试过获取母头?
  • 为什么不使用预建版本?实施 'org.webrtc:google-webrtc:1.0.+'
  • 其实我正在开发自己的库。我必须在 Native Stack 中进行一些更改。出于这个原因,我选择了 WebRTC 原生开发环境。

标签: linux build webrtc webrtc-android


【解决方案1】:

Usman,按照我按照以下步骤操作,我能够生成有效的 webrtc aar 模块:

 git checkout origin/master
 gclient revert
 gclient sync

您的问题将得到解决。您正在检查一个位于源后面的分支,并且没有构建您的 libwebrtc.aar

所需的所有依赖项和模块

【讨论】:

  • 实际上,我正在处理branch-heads,所以这是一个问题。我已重试使用origin/master 分支,然后我尝试了上述命令,它对我有用。
  • 在上述命令中,对我有用的是 gclient revert 而不是 gclient reset。所以我已经更正了它,又犯了一个错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多