NordicSemiconductor / Android-DFU-Library

Device Firmware Update library and Android app
http://www.nordicsemi.com/dfu
BSD 3-Clause "New" or "Revised" License
771 stars 272 forks source link

The ZIP file must contain an Application, a Soft Device and/or a Bootloader. #360

Closed baconcheese113 closed 2 years ago

baconcheese113 commented 2 years ago

DFU Bootloader version:

Device information (please complete the following information):

Currently implementing DFU in a flutter app which is using nordic-dfu and getting the following logs when trying to start the DFU

I/DfuBaseService(26041): DFU service created. Version: 2.0.3
I/DfuBaseService(26041): Starting DFU service in foreground
W/DfuArchiveInputStream(26041): Manifest failed to be parsed. Did you add 
W/DfuArchiveInputStream(26041): -keep class no.nordicsemi.android.dfu.** { *; }
W/DfuArchiveInputStream(26041): to your proguard rules?
E/DfuBaseService(26041): An exception occurred while calculating file size
E/DfuBaseService(26041): java.io.IOException: The ZIP file must contain an Application, a Soft Device and/or a Bootloader.
E/DfuBaseService(26041):    at no.nordicsemi.android.dfu.internal.ArchiveInputStream.<init>(ArchiveInputStream.java:266)
E/DfuBaseService(26041):    at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1457)
E/DfuBaseService(26041):    at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1195)
E/DfuBaseService(26041):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
E/DfuBaseService(26041):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/DfuBaseService(26041):    at android.os.Looper.loop(Looper.java:214)
E/DfuBaseService(26041):    at android.os.HandlerThread.run(HandlerThread.java:65)
I/DfuBaseService(26041): DFU service destroyed

The zip was built through the nRF Connect Extension in VS Code with the west build command and the output zip has both the app_update.bin and the manifest.json which looks like:

{
    "format-version": 0,
    "time": 1663314513,
    "files": [
        {
            "load_address": 66048,
            "version_MCUBOOT": "0.0.0+0",
            "type": "application",
            "board": "nrf52840dk_nrf52840",
            "soc": "nRF52840_QIAA",
            "size": 329506,
            "file": "app_update.bin",
            "modtime": 1663314511
        }
    ],
    "name": "test",
    "firmware": {
        "zephyr": {
            "revision": "be360e7db2db7e1f0e9fcac686a08e62e350bf55"
        },
        "nrf": {
            "revision": "053756565898659278f957e5f58000cc0491a88d"
        }
    }
}

and my app/src/proguard-rules.pro contains

-keep class no.nordicsemi.android.dfu.** { *; }

Can you offer any insight into how I might be able to fix this? I read through the other issues with the same error message but their fixes didn't solve my issue

philips77 commented 2 years ago

Hi, you're using a wrong library. This dfu library supports Legacy and Secure DFU from nRF5 SDK. You're using NCS (nRF Connect SDK), which is using MCU manager subsystem for firmware update.

Please, use nRF Connect Device Manager library instead.