Android-DFU-Library icon indicating copy to clipboard operation
Android-DFU-Library copied to clipboard

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

Open tompi opened this issue 1 year ago • 5 comments

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

tompi avatar Dec 22 '23 13:12 tompi

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.

philips77 avatar Jan 02 '24 16:01 philips77

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.

Silverdark avatar Feb 06 '24 12:02 Silverdark

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.

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.

Silverdark avatar Feb 16 '24 23:02 Silverdark

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

tompi avatar Feb 17 '24 09:02 tompi

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.

ksidirop-laerdal avatar May 22 '24 19:05 ksidirop-laerdal