{"id":2113,"date":"2023-04-02T06:51:08","date_gmt":"2023-04-01T22:51:08","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2113"},"modified":"2023-04-05T20:45:33","modified_gmt":"2023-04-05T12:45:33","slug":"compiling-webrtc-for-android","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/02\/compiling-webrtc-for-android\/","title":{"rendered":"\u7f16\u8bd1WebRTC for Android"},"content":{"rendered":"<h2>\u5b98\u65b9\u6e90\u7801<\/h2>\n<p>\u5b98\u65b9WebRTC\u6e90\u7801\uff0c\u5730\u5740\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/chromium.googlesource.com\/external\/webrtc.git\">https:\/\/chromium.googlesource.com\/external\/webrtc.git<\/a><\/p>\n<blockquote>\n<p>\u9700\u8981\u7ffb\u5899\u4e0d\u7a33\u5b9a\uff0c\u5efa\u8bae\u8d2d\u4e70\u7f8e\u56fd\u7684\u670d\u52a1\u5668<\/p>\n<\/blockquote>\n<p><!-- more --><\/p>\n<h2>\u4f7f\u7528\u7b2c\u4e09\u65b9\u811a\u672c\u6784\u5efa<\/h2>\n<pre><code>\/\/\u4f7f\u7528\u7b2c\u4e09\u65b9\u6784\u5efa\u811a\u672c\n# git clone https:\/\/github.com\/pristineio\/webrtc-build-scripts.git\n# cd webrtc-build-scripts\n# source android\/build.sh\n# install_dependencies  \/\/\u5b89\u88c5\u9700\u8981\u7684\u4f9d\u8d56\u5de5\u5177\uff085\u5206\u949f\uff09\n# get_webrtc  \/\/\u4e0b\u8f7dwebrtc\u6e90\u7801\uff085\u4e2a\u5c0f\u65f6\uff09<\/code><\/pre>\n<pre><code>\/\/\u7f16\u8bd1\u5f97\u5230release\u7248\u672cso\u5e93\uff08\u5f88\u5c0f\uff09\uff087\u4e2a\u5c0f\u65f6\uff09\n# export WEBRTC_DEBUG=false\n# build_apprtc<\/code><\/pre>\n<p>Release\u7f16\u8bd1\u7ed3\u679c\u76ee\u5f55\uff1a<\/p>\n<pre><code>webrtc-build-scripts\/android\/webrtc\/libjingle_peerconnection_builds\/Release<\/code><\/pre>\n<ul>\n<li>so\u5e93\uff1a<code>libjingle_peerconnection_so.so<\/code><\/li>\n<li>jar\u5305\uff1a<code>base_java.jar<\/code>\u3001<code>libjingle_peerconnection.jar<\/code><\/li>\n<\/ul>\n<p><code>org.webrtc.voiceengine<\/code>\u7684jar\u5305\u76ee\u5f55\uff1a<\/p>\n<pre><code>webrtc-build-scripts\/android\/webrtc\/src\/out_android_arm\/Release\/lib.java\/webrtc\/modules\/audio_device<\/code><\/pre>\n<p>Android\u793a\u4f8b\u9879\u76ee\u76ee\u5f55\uff1a<\/p>\n<pre><code>webrtc-build-scripts\/android\/webrtc\/src\/webrtc\/examples\/androidapp<\/code><\/pre>\n<p>\u82e5\u51fa\u73b0\u95ee\u9898\uff1a<\/p>\n<pre><code>.\/install-build-deps-android.sh: line 25: .\/install-build-deps.sh: No such file or directory<\/code><\/pre>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<pre><code># curl https:\/\/chromium.googlesource.com\/chromium\/src\/+\/master\/build\/install-build-deps.sh?format=TEXT | base64 -d &gt; install-build-deps.sh\n# chmod u+x .\/install-build-deps.sh<\/code><\/pre>\n<p>\u82e5\u51fa\u73b0\u95ee\u9898\uff1a<\/p>\n<pre><code>Reading state information... Done\nE: Unable to locate package openjdk-8-jre\nE: Unable to locate package openjdk-8-jdk\n\nAutomatic java installation failed.\n`java -version` reports:\njava version &quot;1.7.0_121&quot;\nOpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.14.04.3)\nOpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)\n\n`javac -version` reports:\n.\/install-build-deps-android.sh: line 65: javac: command not found\n\nPlease ensure that JDK 8 is installed and resolves first in your PATH.\n`which java` reports: \/usr\/bin\/java\n`which javac` reports: \nYou might also try running:\n    sudo update-java-alternatives -s java-1.8.0-openjdk-amd64<\/code><\/pre>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/stackoverflow.com\/questions\/32942023\/ubuntu-openjdk-8-unable-to-locate-package\">http:\/\/stackoverflow.com\/questions\/32942023\/ubuntu-openjdk-8-unable-to-locate-package<\/a><\/p>\n<pre><code># update-java-alternatives -l  \/\/\u9ed8\u8ba4\u5b89\u88c5openjdk-7\n# apt-get install python-software-properties software-properties-common  \/\/\u5b89\u88c5\u4f9d\u8d56\n# add-apt-repository ppa:openjdk-r\/ppa  \/\/\u6dfb\u52a0\u6e90\n# apt-get update\n# apt-get install openjdk-8-jdk\n# update-java-alternatives -l  \/\/Java7\u548cJava8\u5171\u5b58\n# sudo update-alternatives --config java  \/\/\u914d\u7f6e\u4f7f\u7528Java7\u8fd8\u662fJava8<\/code><\/pre>\n<pre><code>$ sudo mkdir \/mnt\/webrtc\n$ sudo mount -t vboxsf webrtc \/mnt\/webrtc  \/\/\u6302\u8f7d\u5171\u4eab\u6587\u4ef6\u5939\n$ sudo umount -f \/mnt\/webrtc  \/\/\u5378\u8f7d\u5171\u4eab\u6587\u4ef6\u5939<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u6e90\u7801 \u5b98\u65b9WebRTC\u6e90\u7801\uff0c\u5730\u5740\uff1ahttps:\/\/chromium.googlesource.com\/ex [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[534],"tags":[537],"class_list":["post-2113","post","type-post","status-publish","format-standard","hentry","category-android-audio-video","tag-webrtc"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2113"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2113\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}