tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
84.36k stars 2.54k forks source link

[bug] Audio Permission Not Working in Tauri Android App Despite Manifest Declaration #10846

Open gato25 opened 2 months ago

gato25 commented 2 months ago

Describe the bug

I'm trying to use navigator.mediaDevices.getUserMedia to record audio. However, I'm consistently getting a "not-allowed" error, even after adding the necessary permission to the AndroidManifest.xml and granting the permission on the device.

  1. Added the following permission to AndroidManifest.xml: <uses-permission android:name="android.permission.RECORD_AUDIO" />

  2. Manually allowed the audio permission for the app in the Android settings.

  3. Implemented the audio recording using the following code:

    async function startRecording() {
    try {
    const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
    // Further implementation...
    } catch (error) {
    console.error("Error accessing the microphone", error);
    }
    }

Are there any additional steps required to properly set up audio permissions in a Tauri Android app?

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22621 x86_64 (X64)
    ✔ WebView2: 128.0.2739.54
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.80.0 (051478957 2024-07-21)
    ✔ cargo: 1.80.0 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.16.0
    - pnpm: 9.6.0
    - npm: 10.8.1
    - bun: 1.1.24

[-] Packages
    - tauri 🦀: 2.0.0-rc.8
    - tauri-build 🦀: 2.0.0-rc.7
    - wry 🦀: 0.42.0
    - tao 🦀: 0.29.1
    - @tauri-apps/api : 2.0.0-rc.4
    - @tauri-apps/cli : 2.0.0-rc.8

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.0-rc.2
    - @tauri-apps/plugin-shell : 2.0.0-rc.0 (outdated, latest: 2.0.0-rc.1)

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 2 months ago

Are there any additional steps required to properly set up audio permissions in a Tauri Android app?

As far as i know what you listed here was enough for others in the past 🤔

https://discord.com/channels/616186924390023171/1207729770775838750 / https://discord.com/channels/616186924390023171/1263134040442277898/1263134040442277898

No idea what the issue could be, maybe it's the wrong AndroidManifest file (can't remember if there are multiple) or maybe the way you enabled audio permissions was wrong/not enough. Can you try adding <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> and see if that makes it prompt for permissions?