<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qt 6.5.3 on Android: ﻿No audio device detected]]></title><description><![CDATA[<p dir="auto">In my application I try to play some small WAV files. The code I wrote works on all operating systems except on Android. There I get the following error at the moment the audio file should be played:</p>
<pre><code>W/TPanel  : java.lang.NullPointerException: Attempt to invoke virtual method 'android.media.AudioDeviceInfo[] android.media.AudioManager.getDevices(int)' on a null object reference
W/TPanel  : 	at org.qtproject.qt.android.multimedia.QtAudioDeviceManager.getAudioDevices(QtAudioDeviceManager.java:181)
W/TPanel  : 	at org.qtproject.qt.android.multimedia.QtAudioDeviceManager.getAudioOutputDevices(QtAudioDeviceManager.java:74)
W/TPanel  : 
W/TPanel  : No audio device detected
</code></pre>
<p dir="auto">Here is the code snipped used to play the file:</p>
<pre><code>#include &lt;QtMultimediaWidgets/QVideoWidget&gt;
#include &lt;QtMultimedia/QMediaPlayer&gt;
#include &lt;QAudioOutput&gt;
#include &lt;QMediaMetaData&gt;
#include &lt;QMediaFormat&gt;
#include &lt;QMediaDevices&gt;

/* ... */

void MainWindow::playSound(const string&amp; file)
{
    qtDebug() &lt;&lt; "Playing file " &lt;&lt; file;

    if (!mMediaPlayer)
    {
        mMediaPlayer = new QMediaPlayer(this);
        mAudioOutput = new QAudioOutput(this);
        mMediaPlayer-&gt;setAudioOutput(mAudioOutput);
        connect(mMediaPlayer, &amp;QMediaPlayer::playingChanged, this, &amp;MainWindow::onPlayingChanged);
        connect(mMediaPlayer, &amp;QMediaPlayer::durationChanged, this, &amp;MainWindow::onDurationChanged);
        connect(mMediaPlayer, &amp;QMediaPlayer::metaDataChanged, this, &amp;MainWindow::onMetaDataChanged);
        connect(mMediaPlayer, &amp;QMediaPlayer::mediaStatusChanged, this, &amp;MainWindow::onMediaStatusChanged);
        connect(mMediaPlayer, &amp;QMediaPlayer::errorOccurred, this, &amp;MainWindow::onPlayerError);
    }

    mMediaPlayer-&gt;setSource(QUrl::fromLocalFile(QString::fromStdString(file)));

    if (!mMediaPlayer-&gt;isAvailable())
    {
        qtDebug() &lt;&lt; "WARNING: No audio modul found!";
        return;
    }

    if (mMediaPlayer-&gt;isPlaying())
    {
        mMediaPlayer-&gt;stop();
        mMediaPlayer-&gt;setPosition(0);
    }

    mMediaPlayer-&gt;play();
}
</code></pre>
<p dir="auto">In header file the class is defined. Here a shortened excerpt:</p>
<pre><code>#include &lt;QMainWindow&gt;
#include &lt;QMediaPlayer&gt;

class QAudioOutput;

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
        MainWindow();
        ~MainWindow();

    private slots:
        void onDurationChanged(qint64 duration);
        void onMetaDataChanged();
        void onPlayingChanged(bool plying);
        void onPlayerError(QMediaPlayer::Error error, const QString &amp;errorString);
        void onMediaStatusChanged(QMediaPlayer::MediaStatus status);

    private:
        void playSound(const std::string&amp; file);
        void stopSound();
        void muteSound(bool state);
        void setVolume(int volume);

        QMediaPlayer *mMediaPlayer{nullptr};
        QAudioOutput *mAudioOutput{nullptr};
}
</code></pre>
<p dir="auto">I tried the player example and it worked. The code I wrote is based on the example. I checked the permissions and other settings and compared it with the example, but don't see any significant difference. Because the example works, the error must be in my code. But where?</p>
<p dir="auto">A.T.</p>
]]></description><link>https://forum.qt.io/topic/163028/qt-6.5.3-on-android-no-audio-device-detected</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 19:51:40 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/163028.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Aug 2025 10:14:13 GMT</pubDate><ttl>60</ttl></channel></rss>