fengqiangboy / flutter-nordic-dfu

Flutter Nordic dfu
MIT License
109 stars 76 forks source link

DFU only works while using flutter run #9

Closed Knightro63 closed 4 years ago

Knightro63 commented 5 years ago

Hi All,

Great work on getting this done. I have been having an issue where using flutter run i have no issues or errors with the zip file in the assets folder or downloading a url and making it into a file and passing it to startDfu. However, I have been experiencing an issue when installing it as an apk or putting the app bundle on the play store. I have tried using the example you have provided as well and I have the same issue. I have narrowed it down to a try catch error at stratDfu. I am using flutter 1.10.7, flutter-nordic-dfu v 2.3.0, and flutter-blue v 0.6.2.

Any help would be great. Thanks

fengqiangboy commented 5 years ago

Can you put more error detail message ?

Knightro63 commented 5 years ago

I was able to print an error message to the screen. PlatformExeception(2,DFU FAILED,device address: xx:xx:xx:xx:xx:xx).

bjornwilliam commented 4 years ago

Edit3, finally a solution:
I checked the issues at the react native version (https://github.com/Pilloxa/react-native-nordic-dfu/issues/74) and there were multiple issues detailing the same problem we have. If you're using proguard do this: Open android/app/proguard-rules.pro and add -keep class no.nordicsemi.android.dfu.* { ; }

I am having the same issue. Trying to figure it out, but no solution yet.

Edit: I think its caused by the dfu file, The error message from startDfu is "DFU FILE ERROR" . I am running startDfu with fileInAsset: true. Im trying to understand why assets are working differently between flutter run --release vs running the release apk.

Edit2: I also tried copying the zip file from assets like this: Directory directory = await getApplicationDocumentsDirectory(); var dbPath = join(directory.path, fileName); ByteData data = await rootBundle.load(assetPath); List<int> bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); await File(dbPath).writeAsBytes(bytes);

and then sending an absolute path to FlutterNordicDfu.startDfu. This worked in flutter run --relase/ debug but not with a release apk (same error message: "DFU FILE ERROR" ).

zwells commented 4 years ago

@fengqiangboy @bjornwilliam Edit3 fixed the issue for me as well! Thank You!

MrHazee commented 4 years ago

Edit3 worked for me as well! Thanks a lot