Unsupported Operation Exception on API level 29 and 30 devices.
See original GitHub issueDescribe 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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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).
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.