fengqiangboy / flutter-nordic-dfu

Flutter Nordic dfu
MIT License
109 stars 76 forks source link

The app is crashing every time I try dfu #18

Open edsonboldrini opened 4 years ago

edsonboldrini commented 4 years ago

The stack trace of the app:

I/DfuBaseService(12097): DFU service created. Version: 1.10.1
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=b7bb7287-1d57-4902-bc66-9e8d952bf87e
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
I/zygote64(12097): Do partial code cache collection, code=123KB, data=76KB
I/zygote64(12097): After code cache collection, code=123KB, data=76KB
I/zygote64(12097): Increasing code cache capacity to 512KB
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): An error occurred while connecting to the device:133
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
I/DfuBaseService(12097): Restarting the service
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=f42fba60-2872-4ab3-bd5e-36d5948d57de
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): Device not reachable. Check if the device with address FF:86:28:CB:AA:04 is in range, is advertising and is connectable
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
I/DfuBaseService(12097): Restarting the service
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=98b70f5a-daad-4c2d-97ca-8a9c3cc2f46c
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): Device not reachable. Check if the device with address FF:86:28:CB:AA:04 is in range, is advertising and is connectable
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
W/FlutterJNI(12097): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: com.timeyaa.flutter_nordic_dfu/method. Response ID: 0
W/FlutterJNI(12097): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: com.timeyaa.flutter_nordic_dfu/method. Response ID: 0
I/DfuBaseService(12097): DFU service destroyed
D/AndroidRuntime(12097): Shutting down VM
E/AndroidRuntime(12097): FATAL EXCEPTION: main
E/AndroidRuntime(12097): Process: com.dersalis.dersalis_support, PID: 12097
E/AndroidRuntime(12097): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.app.Activity.getSystemService(java.lang.String)' on a null object reference
E/AndroidRuntime(12097):    at com.timeyaa.flutternordicdfu.FlutterNordicDfuPlugin$2.run(FlutterNordicDfuPlugin.java:280)
E/AndroidRuntime(12097):    at android.os.Handler.handleCallback(Unknown Source:2)
E/AndroidRuntime(12097):    at android.os.Handler.dispatchMessage(Unknown Source:4)
E/AndroidRuntime(12097):    at android.os.Looper.loop(Unknown Source:155)
E/AndroidRuntime(12097):    at android.app.ActivityThread.main(Unknown Source:65)
E/AndroidRuntime(12097):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12097):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
E/AndroidRuntime(12097):    at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
W/FlutterEngine(13882): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@97042d0) but could not find and invoke the GeneratedPluginRegistrant.
edsonboldrini commented 4 years ago

Hello, some update? Still getting this error 👆

07ami commented 3 years ago

Have you solved this problem? I have encountered same problem

Knightro63 commented 3 years ago

Solution:

Go to flutter_nordic_dfu-3.0.0 open FlutterNordicDfuPlugin.java and change line 284 form:

final NotificationManager manager = (NotificationManager) registrar.activity().getSystemService(Context.NOTIFICATION_SERVICE);

to:

final NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

This should fix any issue you are having.