Cordova Android WebRTC Won't Capture Video - AUDO ONLY. Permissions issue?
<p>I have cordova app that uses WebRTC and RTCPeerConnection to connect two clients to allow them to chat. It's working successfully in the browser and on iOS (with a webRTC shim). However, only audio is being captured and sent on Android, no video! Here's the code. The video isn't even being attached to the #localVideo elem (<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=253465" rel="nofollow noreferrer">which might be a whole other problem in and of itself</a>)!</p>

<pre><code>navigator.getUserMedia = navigator.getUserMedia ||
                         navigator.webkitGetUserMedia ||
                         navigator.mozGetUserMedia ||
                         navigator.msGetUserMedia
navigator.getUserMedia({video: true, audio: true}, function (stream) {
  var video = document.getElementById('localVideo')
  video.src = window.URL.createObjectURL(stream)
  video.play()
  window.myRTC.pc1.addStream(stream)
  console.log(stream)
  console.log('adding stream to pc1')
  window.myRTC.setupDC1()
  window.myRTC.pc1.createOffer(function (desc) {
    window.myRTC.pc1.setLocalDescription(desc, function () {}, function () {})
    console.log('created local offer', desc)
  },
  function () { console.warn("Couldn't create offer") },
  window.myRTC.sdpConstraints)
}, function (error) {
  console.log('Error adding stream to pc1: ' + error)
})
</code></pre>

<p>I'm fairly convinced this is a permissions issue. Here is a screenshot of the app's permissions on my phone:
<a href="https://i.stack.imgur.com/i05ko.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i05ko.png" alt="my app&#39;s permissions"></a></p>

<p>You can see that "record audio" is present, but not camera, or capture video.</p>

<p>Here's my config.xml:</p>

<pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;widget id="org.unicomm" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0"&gt;
     ....
     &lt;platform name="android"&gt;
        &lt;config-file parent="/manifest" target="AndroidManifest.xml"&gt;
            &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
            &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
            &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
            &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
            &lt;uses-permission android:name="android.permission.RECORD_VIDEO" /&gt;
            &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
            &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
            &lt;uses-feature android:name="android.hardware.camera" /&gt;
            &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
            &lt;uses-feature android:glEsVersion="0x00020000" android:required="true" /&gt;
            &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
            &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
        &lt;/config-file&gt;
    &lt;/platform&gt;
&lt;/widget&gt;
</code></pre>

<p>Strangely, not all of those permissions get written to my AndroidManifest.xml:</p>

<pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="org.unicomm" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true"&gt;
        &lt;activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize"&gt;
            &lt;intent-filter android:label="@string/launcher_name"&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
    &lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
    &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
    &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
    &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
    &lt;uses-permission android:name="android.permission.RECORD_VIDEO" /&gt;
&lt;/manifest&gt;
</code></pre>

<p>As a last ditch effort, I tried using a <a href="https://github.com/NeoLSN/cordova-plugin-android-permission" rel="nofollow noreferrer">permissions plugin</a>:</p>

<pre><code>var permissions = cordova.plugins.permissions;
permissions.requestPermissions(
    [permissions.CAMERA,permissions.RECORD_AUDIO,permissions.RECORD_VIDEO],
    function(status) {console.log(status)
        if(!status.hasPermission) {
            errorCallback();
        } else {
            run();
        }
     },
     function() {
         alert("We need those permissions!")
     }
);
</code></pre>

<p>But it simply returns <code>{hasPermission: true}</code>!</p>