question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unsupported Operation Exception on API level 29 and 30 devices.

See original GitHub issue

Describe your question in detail.

We are facing some issues while AudioTrack creation only on API levels 29 and 30, It throws UnsupportedOperationException while AudioTrack creation, Initially we suspected it to be an issue with offloaded playback but turning it off also did not help with this error. this is the stack trace of this exception.

java.lang.UnsupportedOperationException: Cannot create AudioTrack at android.media.AudioTrack$Builder.build(AudioTrack.java:1018) 
at com.google.android.exoplayer2.audio.DefaultAudioSink$c.b(SourceFile:12) 
at com.google.android.exoplayer2.audio.DefaultAudioSink$c.a(SourceFile:1) 
at com.google.android.exoplayer2.audio.DefaultAudioSink.w(SourceFile:1) 
at com.google.android.exoplayer2.audio.DefaultAudioSink.F(SourceFile:4) 
at com.google.android.exoplayer2.audio.DefaultAudioSink.k(SourceFile:17) 
at uh.b.k(SourceFile:1) at com.google.android.exoplayer2.audio.f.m0(SourceFile:8) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.P(SourceFile:45) at 
com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.t(SourceFile:16) at 
com.google.android.exoplayer2.m.d(SourceFile:139) 
at com.google.android.exoplayer2.m.handleMessage(SourceFile:29) 
at android.os.Handler.dispatchMessage(Handler.java:103) 
at android.os.Looper.loop(Looper.java:214) 
at android.os.HandlerThread.run(HandlerThread.java:67)

it seems the exception originates here, but I was not able to reason out why the state would still be uninitialized after creation?


try {
    final AudioTrack track = new AudioTrack(
            mAttributes, mFormat, mBufferSizeInBytes, mMode, mSessionId, mOffload,
            mEncapsulationMode, mTunerConfiguration);
    if (track.getState() == STATE_UNINITIALIZED) {
        // release is not necessary
        throw new UnsupportedOperationException("Cannot create AudioTrack");
    }
    return track;
} catch (IllegalArgumentException e) {
    throw new UnsupportedOperationException(e.getMessage());
}

Is this a bug with the Android Media API itself? or I am doing something wrong?

Exoplayer version details

we are using exoplayer version 2.16.1; unfortunately, the issue is not reproducible at our end.

cc @saurabhofficial

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
toniheicommented, Jun 17, 2022

I stumbled upon allowedCapturePolicy but it’s uniform across all devices and sessions I don’t know if it can cause some trouble?

Sounds unrelated, but it’s really not possible to say what can cause this without more information from these devices (ideally a bugreport that is likely to give some indication).

The highest errors were on Sony Bravia VH2, and VH1. This definitely indicates a device-specific problem.

0reactions
google-oss-botcommented, Jul 18, 2022

Since there haven’t been any recent updates here, I am going to close this issue.

@LuGO0 if you’re still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnsupportedOperationException - Android Developers
UnsupportedOperationException ; UnsupportedOperationException; UnsupportedOperationException; UnsupportedOperationException. Added in API level 1.
Read more >
Robolectric and Android SDK 29 - Stack Overflow
Look like I'm missing something then. When I run my unit tests I get an error message "IllegalArgumentException: API level 29 is not...
Read more >
How to Fix the Unsupported Operation Exception in Java
UnsupportedOperationException is a Java runtime exception that occurs when an unsupported operation is requested but could not be performed.
Read more >
How to Solve Java List UnsupportedOperationException?
The UnsupportedOperationException is one of the common exceptions that occur when we are working with some API of list implementation.
Read more >
Use of All files access (MANAGE_EXTERNAL_STORAGE ...
This is only applicable to apps that target Android 11 (API level 30) and declare the MANAGE_EXTERNAL_STORAGE permission, which is added in Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found