Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BEWARE of the linked fork in the readme #169

Open
CptFabulouso opened this issue Jun 29, 2022 · 4 comments
Open

BEWARE of the linked fork in the readme #169

CptFabulouso opened this issue Jun 29, 2022 · 4 comments

Comments

@CptFabulouso
Copy link

If you do not target Android 12 and your app is running on Android 12, the suggest fork Salt-PepperEngineering/react-native-nordic-dfu will somehow remove BLUETOOTH_CONNECT and BLUETOOTH_SCAN permissions (which are granted automatically if you do not target Android 12), leading to your app crashing whenever using Bluetooth.

@manualexSP
Copy link

Hi @CptFabulouso, on my project, I'm not targeting android 12 and I don't have this problem.
On build.gradle I have :

       minSdkVersion = 21
       compileSdkVersion = 30
       targetSdkVersion = 30

And we tested on several android 12 devices and we didn't have any problems.
The fix for the android 12 crash issue was to update the Android-DFU-Library from 1.8.0 to 2.0.1 and the target SDK to 31.

Could you please give me more information about your problem maybe I missed something?

@CptFabulouso
Copy link
Author

CptFabulouso commented Jul 11, 2022

After using the forked version our app started to crash because of this
Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource { uid = 10052, packageName = com.xxx.app, attributionTag = null, token = android.os.BinderProxy@f8ab6f, next = null }: AdapterService getBondedDevices
I was able to replicate the issue on my side by first installing the last working version of our app, then installing new version with the forked lib (the only thing changed) and the app crashed.
Our gradle:

buildToolsVersion = "30.0.3"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
supportLibVersion = "28.0.0"
playServicesVersion = "17.0.0"
androidMapsUtilsVersion = "2.3.0"

Not sure why we have compileSdkVersion set to 31 right now, could that be the reason?

Besides this lib we are using react-native-ble-manager: 7.6.3 for bluetooth. react-native: 0.6.3

@manualexSP
Copy link

@CptFabulouso ok so we have the same gradle and react-native version, and I'm using the ble-plx for Bluetooth.

Can you please try to declare the permissions like this:

    <uses-permission
        android:name="android.permission.BLUETOOTH"
        android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="30" />
    <!-- API 31+ -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

If this is not working then I will set the SDK to 30 and test to see how it works, it shouldn't be a problem because it was just an extra thing that I did.

@CptFabulouso
Copy link
Author

@manualexSP Hi, I finally got around to test this once again with clean RN project to eliminate issues in my setup. I created this repo to test this out https://github.com/CptFabulouso/nordic-dfu-fork-issue-repo

There's readme how to simulate the crash, look for my-case, which is what happened in my project. I basically had some old setup in manifest with

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

and with that the app was working on Android 12 fine. After using the fork app crashes and it is required to specify and use BLUETOOTH_CONNECT(SCAN) even without changing the targetSdkVersion. You can look at Case fix commit in my-case branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants