Can't get current audio device
I'm trying to use the getCommunicationDevice() method, but I'm getting this exception: PlatformException(Error: java.lang.RuntimeException: Requires API level 31, null, null, null).
The Android documentation says that it is supported starting from version 31, I am using version 33. What can I do in such a situation? There may be another method, but I haven't found it.
This error refers to the version of Android that is installed on the user's device, not the target SDK level you have set in your build.gradle. If your minSdkVersion is 31, you should have no issue because users on older devices simply won't be allowed to install the app. But if your minSdkVersion is lower than 31 and some users have versions of Android above and below 31, you would need to write conditional code to check at runtime if the user's phone supports that feature or not depending on their API level.