在 Ubuntu 上为 android 构建 WebRTC 时出错
Error while building WebRTC for android on Ubuntu
我正在尝试在 Ubuntu 16.04 上为 Android 构建 WebRTC。我已按照以下位置提到的步骤进行操作:
https://medium.com/@abdularis/how-to-compile-native-webrtc-from-source-for-android-d0bac8e4c933(我在其他链接中也发现了类似的步骤)
我查看了版本:branch-heads/m79
我在使用命令构建代码时遇到以下错误:
python tools_webrtc/android/build_aar.py
ERROR at //build/config/android/internal_rules.gni:3051:7: Assertion failed.
assert(_is_annotation_processor || _is_java_binary || _has_sources)
^-----
See //build/config/android/rules.gni:1489:5: whence it was called.
java_library_impl(target_name) {
^-------------------------------
See //build/config/android/rules.gni:1844:5: whence it was called.
java_library(target_name) {
^--------------------------
See //webrtc.gni:850:5: whence it was called.
android_library(target_name) {
^-----------------------------
See //rtc_base/BUILD.gn:1359:3: whence it was called.
rtc_android_library("base_java") {
^---------------------------------
See //BUILD.gn:423:7: which caused the file to be included.
"rtc_base",
^---------
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 210, in BuildAar
extra_ninja_switches)
File "build_aar.py", line 166, in Build
_RunGN(gn_args_list)
File "build_aar.py", line 93, in _RunGN
subprocess.check_call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '/home/architsinha/work/WebRTC_Android/src/third_party/depot_tools/gn.py', 'gen', '/tmp/tmpuxZSnM/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
如果我通过 运行 命令尝试其他方法
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
我收到以下错误:
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") {
^------------------------------------
我该如何解决这个错误?有没有漏掉的步骤?
可能需要尝试几次,但 运行 gclient sync
几次对我有用。
获取所有文件可能需要很长时间,如果中断则无法检索它们。
我遇到了同样的问题。在执行以下命令时,请确保您使用 Linux 终端 的相同(only-1
)选项卡进行 WebRTC 本机开发。
Please visit this article which is quite helpful for webrtc native
development as well as the compilation of webrtc native stack: Compilation of WebRtc Library for Android
首先,请确保您已经安装了以下内容,如果没有,请使用这些命令来执行此操作:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get install openjdk-8-jdk
- sudo apt-get install pkg-config
- sudo apt-get update
之后,开始下面的步骤。根据机器规格和网速,每一步都需要自己的时间,因此请确保每一步都没有中断地完成。
1- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2- export PATH="$PATH:${HOME}/depot_tools"
3- mkdir webrtc_android
3.1- cd webrtc_android
4- fetch --nohooks webrtc_android
5- gclient sync
6- cd src/
7- ./build/install-build-deps.sh
8- git branch -r
9- git checkout origin/master
# To check you're in origin/master branch
10- git branch
11- tools_webrtc/android/build_aar.py
原来你会在webrtc_android/src/
目录下编译构建libwebrtc.aar
现在,如果您已经用 branch-heads/m79
完成了 step-7
的任务,那么
select origin/master
的 branch
而不是 m79
。为此,请尝试以下步骤:
确保你在这个目录中 webrtc_android/src/
:
- git checkout origin/master
# To make sure you're using origin/master
- git branch
- gclient revert
- gclient sync
- tools_webrtc/android/build_aar.py
希望您的问题得到解决。目前,您正在检查 origin/master
后面的一个分支,那里没有构建 libwebrtc.aar
.
所需的所有依赖项和模块。
现在,如果您尝试这两个过程来构建 WebRTC,例如:
1- 使用 AAR 构建工具 (./tools_webrtc/android/build_aar.py
)
2-使用手动编译(gn gen out/Debug --args='target_os="android" target_cpu="arm"'
)
2.1- 编译 (ninja -C out/Debug
)
两个程序都可以。
我正在尝试在 Ubuntu 16.04 上为 Android 构建 WebRTC。我已按照以下位置提到的步骤进行操作: https://medium.com/@abdularis/how-to-compile-native-webrtc-from-source-for-android-d0bac8e4c933(我在其他链接中也发现了类似的步骤)
我查看了版本:branch-heads/m79
我在使用命令构建代码时遇到以下错误:
python tools_webrtc/android/build_aar.py
ERROR at //build/config/android/internal_rules.gni:3051:7: Assertion failed.
assert(_is_annotation_processor || _is_java_binary || _has_sources)
^-----
See //build/config/android/rules.gni:1489:5: whence it was called.
java_library_impl(target_name) {
^-------------------------------
See //build/config/android/rules.gni:1844:5: whence it was called.
java_library(target_name) {
^--------------------------
See //webrtc.gni:850:5: whence it was called.
android_library(target_name) {
^-----------------------------
See //rtc_base/BUILD.gn:1359:3: whence it was called.
rtc_android_library("base_java") {
^---------------------------------
See //BUILD.gn:423:7: which caused the file to be included.
"rtc_base",
^---------
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 210, in BuildAar
extra_ninja_switches)
File "build_aar.py", line 166, in Build
_RunGN(gn_args_list)
File "build_aar.py", line 93, in _RunGN
subprocess.check_call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '/home/architsinha/work/WebRTC_Android/src/third_party/depot_tools/gn.py', 'gen', '/tmp/tmpuxZSnM/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
如果我通过 运行 命令尝试其他方法
gn gen out/Debug --args='target_os="android" target_cpu="arm"'
我收到以下错误:
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") {
^------------------------------------
我该如何解决这个错误?有没有漏掉的步骤?
可能需要尝试几次,但 运行 gclient sync
几次对我有用。
获取所有文件可能需要很长时间,如果中断则无法检索它们。
我遇到了同样的问题。在执行以下命令时,请确保您使用 Linux 终端 的相同(only-1
)选项卡进行 WebRTC 本机开发。
Please visit this article which is quite helpful for webrtc native development as well as the compilation of webrtc native stack: Compilation of WebRtc Library for Android
首先,请确保您已经安装了以下内容,如果没有,请使用这些命令来执行此操作:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get install openjdk-8-jdk
- sudo apt-get install pkg-config
- sudo apt-get update
之后,开始下面的步骤。根据机器规格和网速,每一步都需要自己的时间,因此请确保每一步都没有中断地完成。
1- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2- export PATH="$PATH:${HOME}/depot_tools"
3- mkdir webrtc_android
3.1- cd webrtc_android
4- fetch --nohooks webrtc_android
5- gclient sync
6- cd src/
7- ./build/install-build-deps.sh
8- git branch -r
9- git checkout origin/master
# To check you're in origin/master branch
10- git branch
11- tools_webrtc/android/build_aar.py
原来你会在webrtc_android/src/
目录下编译构建libwebrtc.aar
现在,如果您已经用 branch-heads/m79
完成了 step-7
的任务,那么
select origin/master
的 branch
而不是 m79
。为此,请尝试以下步骤:
确保你在这个目录中 webrtc_android/src/
:
- git checkout origin/master
# To make sure you're using origin/master
- git branch
- gclient revert
- gclient sync
- tools_webrtc/android/build_aar.py
希望您的问题得到解决。目前,您正在检查 origin/master
后面的一个分支,那里没有构建 libwebrtc.aar
.
现在,如果您尝试这两个过程来构建 WebRTC,例如:
1- 使用 AAR 构建工具 (./tools_webrtc/android/build_aar.py
)
2-使用手动编译(gn gen out/Debug --args='target_os="android" target_cpu="arm"'
)
2.1- 编译 (ninja -C out/Debug
)
两个程序都可以。