You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the fork enables jetifier, and I got argument mismatch on the function call that I couldn't resolve. I made the modifications to support v31 and Androidx manually to the non-fork code.
the no.nordic.dfu library hard crashes unless you get permissions spot on. I think they have them incorrect in the manifest, or the ble lib you're using does. The best approach is to completely ignore every sodding bluetooth permission in all the sodding manifests and force your own in the master manifest. After much trial and error these are great for my use case (ble only, no location).
Finally DFU is working again!
<uses-permission android:name="android.permission.INTERNET" />
<!--
HACK: this permission should not be needed on android 12+ devices anymore,
but in fact some manufacturers still need it for BLE to properly work :
https://stackoverflow.com/a/72370969
-->
<uses-permission android:name="android.permission.BLUETOOTH" android:usesPermissionFlags="neverForLocation" android:maxSdkVersion="31" tools:replace="android:maxSdkVersion" tools:remove="android:minSdkVersion" />
<!--
should normally only be needed on android < 12 if you want to:
- activate bluetooth programmatically
- discover local BLE devices
see: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#discover-local-devices.
Same as above, may still be wrongly needed by some manufacturers on android 12+.
-->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:usesPermissionFlags="neverForLocation" android:maxSdkVersion="30" tools:replace="android:maxSdkVersion" tools:remove="android:minSdkVersion" />
<!-- Android 9 (API28) and below require course location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" tools:replace="android:maxSdkVersion" tools:remove="android:minSdkVersion" />
<!-- Android 10 and 11 (API29,30) require fine location -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:minSdkVersion="29" android:maxSdkVersion="30" tools:replace="android:maxSdkVersion,android:minSdkVersion" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" tools:remove="android:maxSdkVersion,android:minSdkVersion" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" android:usesPermissionFlags="neverForLocation" tools:remove="android:maxSdkVersion,android:minSdkVersion" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" tools:remove="android:maxSdkVersion,android:minSdkVersion" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
...
And then you need all the runtime permissions as well...
const permissions = [
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT
];
// shouldn't be needed on 31 but some manufacturers still require
if (Platform.Version <= 31) {
permissions.push(PermissionsAndroid.PERMISSIONS.BLUETOOTH);
}
if (Platform.Version <= 30) {
permissions.push(PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADMIN);
}
if (Platform.Version <= 28) {
permissions.push(PermissionsAndroid.PERMISSIONS.ACCESS_COURSE_LOCATION);
} else if ([29.30].includes(Platform.Version)) {
permissions.push(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
}
await PermissionsAndroid.requestMultiple(permissions);
}
The text was updated successfully, but these errors were encountered:
andrewcharnley
changed the title
Android 12+ - README if you get a crash, or try the fork.
Android 12+ - README if you get a crash or attempt to use the fork.
Jul 5, 2023
@andrewcharnley Hi, I'm from the README fork, I just created an new example based on a new react-native project. And is included in the setup as well. Let me know if I can add anything in there :D
Just remove the useJetifier argument I think, this rewrote the function and I got argument mismatch error - it took me all day to work it out! It may not be obvious until you clear metro cache.
Hi all,
After many hours....
the fork enables jetifier, and I got argument mismatch on the function call that I couldn't resolve. I made the modifications to support v31 and Androidx manually to the non-fork code.
the no.nordic.dfu library hard crashes unless you get permissions spot on. I think they have them incorrect in the manifest, or the ble lib you're using does. The best approach is to completely ignore every sodding bluetooth permission in all the sodding manifests and force your own in the master manifest. After much trial and error these are great for my use case (ble only, no location).
Finally DFU is working again!
And then you need all the runtime permissions as well...
The text was updated successfully, but these errors were encountered: