android / connectivity-samples

Multiple samples showing the best practices in connectivity on Android.
Apache License 2.0
1.65k stars 1.32k forks source link

Nearby Connections API - unknown error codes 8037, 8038 and 8039 on Android 12 #255

Open krzdabrowski opened 2 years ago

krzdabrowski commented 2 years ago

I'm developing an app that uses Nearby Connections API with basic P2P strategy. Suddenly, weirdly enough I'm not able to advertise and discover devices on my Pixel 3a with newest Android 12 and Play Services. OnFailureListeners throw these exceptions:

Indeed they cannot be found in docs and source code. I also checked "Rock Papers Scissors" sample and it throws the same error codes.

Of course I reinstalled the app and restarted & updated my phone. I also did the factory reset and it didn't help. But after I downgraded to latest Android 11 using Android Flash Tool, it started working again. Moreover, everything still works fine on Android 11, 10 and 9 using different phones. Coming back to Android 12 makes the issue returning.

I also posted on StackOverflow here but no responses yet.

krzdabrowski commented 2 years ago

I found a solution to the issue, described on SO in detail

Basically you need to update your Bluetooth permission to ones that came in Android 12. I'm not closing this issue because it should be handled more gracefully by API.