> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# WebRTC Android 运行 build_aar.py 报错 You can often set treat_warnings_as_errors=false...
- URL: https://sgpublic.xyz/p/2022/09/6aac9cb1810a4800015335f0/
- Published: 2022-09-15T08:38:44.000Z
- Updated: 2022-09-15T08:38:44.000Z
- Author: Haven Madray
- Tags: 软件开发, Android, #wp-post

编译 `webrtc_android` 时，`build_aar.py` 运行时出现警告：

```
注：xxx.java 使用或覆盖了已过时的 API。
注：有关详细信息，请使用 -Xlint:deprecation 重新编译。
```

随即出现 python 的错误堆栈提示，编译停止并出现以下提示：

```
...
You can often set treat_warnings_as_errors=false to not treat output as failure (useful when developing locally).
[100/30872] ACTION //components/resour…d/toolchain/android:android_clang_armeabi-v7a)
...
```

根据提示推测原因是编译期间出现了警告信息，而 `build_aar.py` 会将警告视为错误而停止编译，但此处警告仅仅是使用了过时的 API，编译本身是没有出错的，于是按照提示添加参数 `treat_warnings_as_errors=false` 就好：

```
$ ./tools_webrtc/android/build_aar.py --extra-gn-args='treat_warnings_as_errors=false'
```

也可以直接在 `build_aar.py` 第 175 行（官方仓库 `branch-heads/5301` 分支）的 `gn_args` 数组中添加：

```
  gn_args = {
      'target_os': 'android',
      'is_debug': False,
      'is_component_build': False,
      'rtc_include_tests': False,
      'treat_warnings_as_errors': False,
      'target_cpu': _GetTargetCpu(arch),
      'use_goma': use_goma,
      'use_remoteexec': use_remoteexec,
  }
```

重新运行即可编译成功。