NordicSemiconductor / Android-DFU-Library

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

Problems with binding for xamarin/maui: string with multiple placeholders #428

Closed tompi closed 2 months ago

tompi commented 7 months ago

Version

2.4.1 (Latest)

Ask the question

Hi, am tagging this as a question, since I dont think this is your bug....

I had some problems binding the latest version, specifically when using produced binding library in a Maui application, I get this compile time error:

res/values/values.xml(2): error APT2000: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

This line seems to be causing the problem:

<string name="dfu_status_uploading_part">Uploading part %d/%d&#8230;</string>

I tried introducing positional format like "Uploading part %1$d/%2$d", but that didnt help. When I just used "Uploading part %d", it worked...

I see you removed the formatted=false on October 2 in commit 4a5c18d (I assume since formatted=false would not interpolate, so you probably just got the percent signs?)

Anyway, I know this is not your problem, but MAYBE you could change it to just have one substitution? (just build the x/y in code and substitute for an %s in the xml)

Its a bit dirty, so I totally understand if you wont do it...

Relevant log output

No response

philips77 commented 6 months ago

Hi, I think it may be related to Android Studio/Lint/Java version. It used to warn about lack of formatted="false" for strings with 2 or more parameters. Now it seems to warn when there is such attribute. I'll try adding it and see if that still compiles.

Silverdark commented 5 months ago

Is there any progress on this topic? I face the same issue when trying to use the latest 2.4.2 version of the library.

Thanks in advance.

andersonvieiragomeslopes commented 5 months ago

Hi @tompi

Have you made any progress with this issue? I have the same problem on another SDK and it is also related to android library binding for maui.

Silverdark commented 5 months ago

I tried introducing positional format like "Uploading part %1$d/%2$d", but that didnt help.

I tried it myself by build an aar file and used it to build a NuGet with bindings. For me this worked so hopefully the PR can solve this.

tompi commented 5 months ago

Yes, i just unzipped the aar, changed the xml file, rezipped and then bound the library. Cumbersome, but it works...

ksidirop-laerdal commented 2 months ago

Having this exact same issue for the exact same cause when trying to build MAUI sample-apps. The build fails with the same kind of error:

0>values.xml(2): Error APT2000 : multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.

0>values.xml: Error APT2261 : file failed to compile.