Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tompi opened this issue Dec 22, 2023 · 6 comments · Fixed by #435
Closed

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

tompi opened this issue Dec 22, 2023 · 6 comments · Fixed by #435
Labels

Comments

@tompi
Copy link
Contributor

tompi commented Dec 22, 2023

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 tompi added the question label Dec 22, 2023
@philips77
Copy link
Member

philips77 commented Jan 2, 2024

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
Copy link
Contributor

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

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
Copy link
Contributor

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
Copy link
Contributor Author

tompi commented Feb 17, 2024

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

@ksidirop-laerdal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants