Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 40 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Streets Of Boston  
View profile  
 More options Dec 6 2010, 2:47 pm
From: Streets Of Boston <flyingdutc...@gmail.com>
Date: Mon, 6 Dec 2010 11:47:23 -0800 (PST)
Local: Mon, Dec 6 2010 2:47 pm
Subject: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
When this string is in my strings.xml

   <string name="home_activity_header_name">%s %s</string>

I get this error when compiling the source-code:
"error: Multiple substitutions specified in non-positional format; did
you mean to add the formatted="false" attribute"

I just upgraded to the newest tools (v 8.0.0) and downloaded the
latest SDK (2.3).
I compile under apil-leverl 8 and i tried compiling under api-level 9.

Why does this error suddenly appear?
Is there a way to get rid of it?

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Dec 6 2010, 2:56 pm
From: Romain Guy <romain...@android.com>
Date: Mon, 6 Dec 2010 11:56:29 -0800
Local: Mon, Dec 6 2010 2:56 pm
Subject: Re: [android-developers] SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

To make this work correctly across multiple locales, you should use the
following syntax:

$1%s $2%s

On Mon, Dec 6, 2010 at 11:47 AM, Streets Of Boston
<flyingdutc...@gmail.com>wrote:

--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Streets Of Boston  
View profile  
 More options Dec 6 2010, 2:56 pm
From: Streets Of Boston <flyingdutc...@gmail.com>
Date: Mon, 6 Dec 2010 11:56:18 -0800 (PST)
Local: Mon, Dec 6 2010 2:56 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
The snipped from the strings.xml in my post above is just an example.
It happens when the value of a string-property has more than one
substitution, e.g.

  <string name="page_number">Page %d out of %d</string>

has the same problem.

This has never been a problem before and I'm using it in my app
correctly.... until I upgraded to SDK 2.3/Tools 8.0.0 just now.

Please help...

On Dec 6, 2:47 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Streets Of Boston  
View profile  
 More options Dec 6 2010, 3:08 pm
From: Streets Of Boston <flyingdutc...@gmail.com>
Date: Mon, 6 Dec 2010 12:08:18 -0800 (PST)
Local: Mon, Dec 6 2010 3:08 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
I tried this in the strings.xml:

<string name="home_activity_header_name">$1%s $2%s</string>

I still get the same error when compiling.

On Dec 6, 2:56 pm, Romain Guy <romain...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Dec 6 2010, 3:11 pm
From: Romain Guy <romain...@android.com>
Date: Mon, 6 Dec 2010 12:11:14 -0800
Local: Mon, Dec 6 2010 3:11 pm
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

My bad, it's %1$s :)

On Mon, Dec 6, 2010 at 12:08 PM, Streets Of Boston
<flyingdutc...@gmail.com>wrote:

--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Dec 6 2010, 3:08 pm
From: Romain Guy <romain...@android.com>
Date: Mon, 6 Dec 2010 12:08:20 -0800
Local: Mon, Dec 6 2010 3:08 pm
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

It wouldn't. What if you translate your app in a language where the second
value should appear first? The translation would be $2%s $1%s and the code
wouldn't change.

On Mon, Dec 6, 2010 at 12:04 PM, Streets Of Boston
<flyingdutc...@gmail.com>wrote:

--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Quigley  
View profile  
 More options Dec 6 2010, 4:09 pm
From: Matt Quigley <matthew.quig...@gmail.com>
Date: Mon, 6 Dec 2010 13:09:53 -0800 (PST)
Local: Mon, Dec 6 2010 4:09 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
On Dec 6, 3:08 pm, Romain Guy <romain...@android.com> wrote:
> It wouldn't. What if you translate your app in a language where the second
> value should appear first? The translation would be $2%s $1%s and the code
> wouldn't change.

That may be the case, sometimes, somewhere.  It isn't all the time.
There may have been some developers giving strings to a translation
company who returned the string translations and didn't tell the
developers that the order of %s and %s was different, and the software
company didn't have any QA in place to catch this, so some strings
appeared funny for that particular translation.

I don't think the answer to solve this problem, that probably happened
once to someone, with a build error instead of a warning.

And please, it would be nice if someone could take the time to
document what exactly the "formatted" attribute of the <string>
element means.  http://developer.android.com/guide/topics/resources/string-resource.html

Thanks,
-Matt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel  
View profile  
 More options Dec 6 2010, 4:13 pm
From: Daniel <velaz...@gmail.com>
Date: Mon, 6 Dec 2010 13:13:41 -0800 (PST)
Local: Mon, Dec 6 2010 4:13 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
What would be the proper way of outputting a % sign, it's giving me
this error on a regular string saying 3%

On Dec 6, 3:08 pm, Romain Guy <romain...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xavier Ducrohet  
View profile  
 More options Dec 6 2010, 4:31 pm
From: Xavier Ducrohet <x...@android.com>
Date: Mon, 6 Dec 2010 13:31:32 -0800
Local: Mon, Dec 6 2010 4:31 pm
Subject: Re: [android-developers] SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
This suddenly appears because, starting with tools r8, applications
are compiled using the latest version of aapt (the tool that compiles
the android resource).

We used to use version of aapt specific to the version of Android you
compiled against, but not anymore.

Benefits of using the latest versions:
- if we add a feature, you'll get it even if you compile against an
older version. For instance, the new mode that automatically insert
debuggable="true" in your manifest would not be usable on older
versions.
- you get bug fixes too, or behavioral changes. In this case, aapt is
more strict, and while that may be annoying at first, this is really
important to use positional format.

Xav

On Mon, Dec 6, 2010 at 11:47 AM, Streets Of Boston

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.

Please do not send me questions directly. Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Quigley  
View profile  
 More options Dec 6 2010, 4:42 pm
From: Matt Quigley <matthew.quig...@gmail.com>
Date: Mon, 6 Dec 2010 13:42:13 -0800 (PST)
Local: Mon, Dec 6 2010 4:42 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
On Dec 6, 4:13 pm, Daniel <velaz...@gmail.com> wrote:

> What would be the proper way of outputting a % sign, it's giving me
> this error on a regular string saying 3%

Outputting just a % sign?  Probably %%.
Or, you can leave it as 3% and add formatted="false".

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Streets Of Boston  
View profile  
 More options Dec 6 2010, 5:18 pm
From: Streets Of Boston <flyingdutc...@gmail.com>
Date: Mon, 6 Dec 2010 14:18:24 -0800 (PST)
Local: Mon, Dec 6 2010 5:18 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
I agree that for internationalization the order spec is important.

However, i read through the changes in the tools and SDK2.3 and I
didn't read about this particular change in aapt (where position is
now required, unless formatted="false" is used). Therefore, the error
came by surprise and it took me a while to figure out (thanks
Romain!).

Also, I only found an example of the positional parameters (1$, 2$,
etc) in an example on this page:
http://developer.android.com/guide/topics/resources/string-resource.html.
I assume that the format is "n$", where n is a digit (or more digits?)
that should appear right after the '%' character. Is this correct? If
not, where can i find more info on this particular format (the
Formatter java-doc does not say anything about the positional
parameters)..

On Dec 6, 4:31 pm, Xavier Ducrohet <x...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Dec 6 2010, 5:23 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Mon, 6 Dec 2010 17:23:00 -0500
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
On Mon, Dec 6, 2010 at 5:18 PM, Streets Of Boston

<flyingdutc...@gmail.com> wrote:
> Also, I only found an example of the positional parameters (1$, 2$,
> etc) in an example on this page:
> http://developer.android.com/guide/topics/resources/string-resource.html.
> I assume that the format is "n$", where n is a digit (or more digits?)
> that should appear right after the '%' character. Is this correct? If
> not, where can i find more info on this particular format (the
> Formatter java-doc does not say anything about the positional
> parameters)..

Sure it does. Sixth paragraph under Class Overview:

"Argument index. Normally, each format specifier consumes the next
argument to format. For convenient localization, it's possible to
reorder arguments so that they appear in a different order in the
output than the order in which they were supplied. For example, "%4$s"
formats the fourth argument (4$) as a string (s)."

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Streets Of Boston  
View profile  
 More options Dec 6 2010, 5:29 pm
From: Streets Of Boston <flyingdutc...@gmail.com>
Date: Mon, 6 Dec 2010 14:29:16 -0800 (PST)
Local: Mon, Dec 6 2010 5:29 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
Yep, i stand corrected. It is mentioned. But only as another example.
Nowhere it says that is has to be right after the '%' character.

On Dec 6, 5:23 pm, Mark Murphy <mmur...@commonsware.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Kerns  
View profile   Translate to Translated (View Original)
 More options Dec 7 2010, 12:57 am
From: Bob Kerns <r...@acm.org>
Date: Mon, 6 Dec 2010 21:57:42 -0800 (PST)
Local: Tues, Dec 7 2010 12:57 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
As someone who's been involved with internationalization of software
for over 25 years -- while I'm certainly glad you provide this syntax,
I think signalling an error is just a bit over the top. A warning
would be sufficient.

Here's why: In my experience (perhaps not comprehensive), the workflow
goes like this: A developer writes the message, in his language of
choice, usually English, but perhaps, say, Japanese, and plops in %s
and friends where appropriate, and arranges the arguments to the
formatting code in the same order as they occur in his format string.

Then someone comes along and whacks him over the head for not
externalizing it for translation, and it is moved to strings.xml or
other localization resource.

Finally, maybe one time in 100, the application is successful enough
to be localized to other languages. One might wish for this to be more
often, but actually I think I'm being generous here.  But it's a pain
to do if the previous step hasn't been done, as a matter of practice.
So we'd like to make that as easy as possible. Really, I don't think
we're even close to making it as easy as we should make it! Especially
since the programmer, and likely his manager as well, will correctly
perceive that the effort stands a high probability of being wasted.

Then finally, if we're lucky, we get to translate the app. If we're
really, really lucky, we'll have a QA department that will try to
reproduce as many of the messages as possible, in the original
language.

Now, off goes string.xml and friends to the localization service,
translator, team member, or maybe the developer's wife. Much of the
time, maybe 80% or more, the strings with multiple %s's will not be
using them in a way that is particularly sensitive to language. They
may be constructing an identifier name, or a list, or may occur in
different sentences, which would not in most cases require reordering.

Your mileage may vary on the frequency, of course. But I'd say the
most common use would be something like "%d cats and %d dogs" -- and
ordering is not the problem you face here, but rather, handling of
plurals.

And you get big kudos for addressing it. I hadn't noticed until now
that <plurals/is documented. I don't know if I'd missed seeing it, or
it's a recent addition to the documentation, but thank you! But "%d
gatos y %d perros" or "%d猫と%d犬?" are perfectly fine, from an ordering
standpoint.

BUT! Your Spanish translator is barfing right now, and it has nothing
to do with positionals. The programmer didn't think about plurals.
(yeah, yeah, he should have. See above for the unfortunate reality).
Your translator has to get the programmer to change the code. Bletch.
That likely requires a whole new release. more expensive QA, etc.
Yikes! Maybe we live with it for now, instead.

Now (next release) it goes to the Japanese translator. Who goes, WTF
is this? Well, OK, maybe more like 「なにこれ?」

What used to be easily translated as "%d猫と%d犬" is now just "%d %s and
%d %s", or maybe by now "%1$d %2$s and %3$d %4$s". What's the context?
Should this be "%1$d%2$sと%3$d%4$s", "%1$d%2$sで、%3$d%4$s", or a dozen
other possibilities? Yes, the first guess is still really the only
likely answer given the presence of %d, but still, you've made the
translation job harder.

Given that the original was in English, which has plurals, the
programmer might have supplied that -- but consider if the original
were in Japanese, which almost entirely lacks the concept. Just like
English lacks the concept of a different set of number words for long
skinny things like pencils, vs flat sheets like paper. In that case,
the first time that plurals will enter the picture will be when the
app gets to the English translator, who will get to barf.

Note that even if the Japanese programmer writes it in English
originally, you're still probably going to have the same situation. In
fact, you're likely to have it even if English is your programmer's
native tongue.

In addition to translation, often the text and wording are manipulated
separately from the code, for marketing and/or usability and/or
branding purposes. So the original text may have been "Pigs: %d,
Cattle: %d", and now it's being rebranded for a pet store by someone
who doesn't even have access to the source, and they want to make the
text style more friendly -- and THIS is the first context in which
plurals need to be handled.

Bottom line on that point is that plurals are a linguistic concern,
and should not be institutionalized in Java code. Plural handling
should be fully externalized -- as part of the format syntax. Say,
perhaps, %(3:MyPlural)$s, which rather than directly referencing an
argument, references a <plural/>, and selects the case based on the
numeric value in parameter 3.

The bottom bottom line is, there really isn't much value in asking
programmers to write in the positional arguments. It's more economical
to do so at the point of reordering, which is only a small subset of
the cases - if you get to that point at all.

If you want to force programmers to do something useful -- force them
to define and document what each parameter MEANS. For example, if you
forced the programmer to give each parameter a NAME, instead of a
position in a getString(...) call, the extra effort would not be
duplicative, and you get some improved robustness for your efforts.

For a really radical suggestion:
in strings.xml: <string id='cats_and_dogs'>%(CATS)d %
(CATS:cat_plural)s and %(DOGS)d %(DOGS:dog_plural)s</string>
in Java: getFormatted(R.string.cats_and_dogs).p("DOGS",
dogCount).p("CATS", catCount).asText();

This fully removes order from the picture, provides some self-
documenting characteristics, separates the concerns properly -- and of
course, is completely incompatible with Java's formatting. Though it
is detectable which is which.

And maybe a translate='no' attribute -- then an automated script could
detect where a translator has mistakenly translated an identifier used
as a database key...very annoying...translation isn't the only reason
strings are externalized.

On Dec 6, 1:31 pm, Xavier Ducrohet <x...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Kerns  
View profile   Translate to Translated (View Original)
 More options Dec 7 2010, 1:57 am
From: Bob Kerns <r...@acm.org>
Date: Mon, 6 Dec 2010 22:57:50 -0800 (PST)
Local: Tues, Dec 7 2010 1:57 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
Reformatted for readability after the newsgroup reformats it:

For a really radical suggestion:

in strings.xml:
<string id='cats_and_dogs'>
%(CATS)d %(CATS:cat_plural)s and %(DOGS)d %(DOGS:dog_plural)s
</string>

in Java:
getFormatted(R.string.cats_and_dogs)
  .p("DOGS", dogCount)
  .p("CATS", catCount)
  .asText();

Also, as I think this is an issue which transcends Android, I've
posted a reworded version of this on my blog:

http://bobkerns.typepad.com/bob_kerns_thinking/2010/12/dear-java-bett...

Feel free to comment about non-Android aspects there.

On Dec 6, 9:57 pm, Bob Kerns <r...@acm.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ecthelion  
View profile  
 More options Dec 7 2010, 4:42 am
From: Ecthelion <ep...@joergjahnke.de>
Date: Tue, 7 Dec 2010 01:42:32 -0800 (PST)
Local: Tues, Dec 7 2010 4:42 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
I agree with Bob that an error is a bit over the top. E.g. I include
software from another company as a library project in one of my apps.
This foreign software uses the old formatting using %s %s inside a few
strings, which is now reported as an error. Now I can neither change
the string, because this might break functionality, nor may I use the
new SDK because this produces an error where a warning would have been
sufficient. So I am stuck with Android 2.2 SDK :-(.

On 7 Dez., 06:57, Bob Kerns <r...@acm.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Dec 7 2010, 7:45 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 7 Dec 2010 07:45:24 -0500
Local: Tues, Dec 7 2010 7:45 am
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

On Tue, Dec 7, 2010 at 4:42 AM, Ecthelion <ep...@joergjahnke.de> wrote:
> I agree with Bob that an error is a bit over the top. E.g. I include
> software from another company as a library project in one of my apps.
> This foreign software uses the old formatting using %s %s inside a few
> strings, which is now reported as an error. Now I can neither change
> the string, because this might break functionality, nor may I use the
> new SDK because this produces an error where a warning would have been
> sufficient. So I am stuck with Android 2.2 SDK :-(.

If it is an Android library project, you can definitely change the
string. That's half of the point of *having* Android library projects
-- so developers can modify resources as needed. In your project,
override the library's string resource with one of your own with the
same name, and it will be used. You do not have to modify the actual
library project yourself.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ecthelion  
View profile  
 More options Dec 7 2010, 10:35 am
From: Ecthelion <ep...@joergjahnke.de>
Date: Tue, 7 Dec 2010 07:35:10 -0800 (PST)
Local: Tues, Dec 7 2010 10:35 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
Yes, if the library project includes all the sources. But in this case
part of the foreign code is inside a jar file. And can I really be
sure that the string is not used somewhere inside this library (e.g.
via getResources().getIdentifier(...)) in a way that breaks once I
modify the resource? In any case I still believe that issueing an
error instead of a warning is over the top.

On 7 Dez., 13:45, Mark Murphy <mmur...@commonsware.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Dec 7 2010, 10:39 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Tue, 7 Dec 2010 10:39:51 -0500
Local: Tues, Dec 7 2010 10:39 am
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

On Tue, Dec 7, 2010 at 10:35 AM, Ecthelion <ep...@joergjahnke.de> wrote:
> Yes, if the library project includes all the sources. But in this case
> part of the foreign code is inside a jar file.

Resources cannot be in a JAR file.

> And can I really be
> sure that the string is not used somewhere inside this library (e.g.
> via getResources().getIdentifier(...)) in a way that breaks once I
> modify the resource?

Yes.

> In any case I still believe that issueing an
> error instead of a warning is over the top.

I am not disputing that.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Kerns  
View profile  
 More options Dec 7 2010, 11:20 am
From: Bob Kerns <r...@acm.org>
Date: Tue, 7 Dec 2010 08:20:03 -0800 (PST)
Local: Tues, Dec 7 2010 11:20 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
There's a terminology conflict at work here.

Class.getResource(String) and friends vs. Context.getResources() and
friends. To add to the confusion, they really *are* performing the
same task, albeit differently and on disjoint data.

The stuff inside a .jar file is accessed with
Class.getResource(String), while strings.xml is accessed via
Context.getResources().

To add further to the confusion, most of my comments could apply to
either, but the main discussion is referring to
Context.getResources().

On Dec 7, 7:39 am, Mark Murphy <mmur...@commonsware.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Quigley  
View profile  
 More options Dec 7 2010, 5:12 pm
From: Matt Quigley <matthew.quig...@gmail.com>
Date: Tue, 7 Dec 2010 14:12:11 -0800 (PST)
Local: Tues, Dec 7 2010 5:12 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
To all the various responses:

1. To the guys asking about plurals, have you seen
http://developer.android.com/guide/topics/resources/string-resource.h...
?

2. To the guys who think the errors for the multiple formatters is
over the top... it isn't just over the top, it has really screwed us
over!

I guarantee you what happened is that someone working with Google
wasn't using positional formatters in the strings, and in the latest
batch of translations, one of the positions was supposed to be moved
and it wasn't.  So, one person at Google (maybe Romain? he was talking
about it's reasoning earlier) decided that it should be an error for
all people everywhere, because of the screwup in the translation.  It
wouldn't have been a problem if this was the way it started out when
Android was initially released, but what actually happened is that the
innocent upgrading of the latest SDK (even though you're supposed to
be able to use any older API levels you want) has made all of our
projects break.

It has made a lot of unnecessary work for me and my team.  We've got
multiple projects with a build machine, everything's F'd now.  If you
upgrade the SDK Tools on the build machine, half the projects don't
release.  Not only that, the same project can have multiple branches
in git.  Even as good as git's merging abilities are, after changing
all of the various strings in various branches (which change often),
now the strings.xml is hell to merge when you add in formatted="false"
to the line.  To create a hotfix on an older version, we are forced to
make manual changes on these old branches.

To put it succinctly, this seemingly innocuous "feature" to error on
all these types of strings whereas before it didn't has invalidated
every old build in our system, period.  There's no way to turn it off,
even if you set the API level to 1.  We can no longer build anything
before 12/6/2010, without creating a special separate build machine
which has an old version of the tools on it.

Okay, this rant is over, have a good rest of your day!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ecthelion  
View profile  
 More options Dec 8 2010, 4:01 am
From: Ecthelion <ep...@joergjahnke.de>
Date: Wed, 8 Dec 2010 01:01:06 -0800 (PST)
Local: Wed, Dec 8 2010 4:01 am
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
On 7 Dez., 16:39, Mark Murphy <mmur...@commonsware.com> wrote:

> On Tue, Dec 7, 2010 at 10:35 AM, Ecthelion <ep...@joergjahnke.de> wrote:
> > Yes, if the library project includes all the sources. But in this case
> > part of the foreign code is inside a jar file.

> Resources cannot be in a JAR file.

Yes, but I never said so. I said foreign "code" is inside the jar
file.

> > And can I really be
> > sure that the string is not used somewhere inside this library (e.g.
> > via getResources().getIdentifier(...)) in a way that breaks once I
> > modify the resource?

> Yes.

Sorry, but the answer is "no".
Context.getResources().getIdentifier(...) allows any resource inside
the project to be accessed via its name. So there could be code inside
the library jar that accesses the string properties that I am to
modify because they contain "%s %s" or similar text. And I can't be
sure that such text then gets processed correctly.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Dec 8 2010, 9:14 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Wed, 8 Dec 2010 09:14:18 -0500
Local: Wed, Dec 8 2010 9:14 am
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

On Wed, Dec 8, 2010 at 4:01 AM, Ecthelion <ep...@joergjahnke.de> wrote:
>> > And can I really be
>> > sure that the string is not used somewhere inside this library (e.g.
>> > via getResources().getIdentifier(...)) in a way that breaks once I
>> > modify the resource?

>> Yes.

> Sorry, but the answer is "no".

No, the answer is yes.

> Context.getResources().getIdentifier(...) allows any resource inside
> the project to be accessed via its name.

Correct.

> So there could be code inside
> the library jar that accesses the string properties that I am to
> modify because they contain "%s %s" or similar text.

Correct.

> And I can't be
> sure that such text then gets processed correctly.

Sure you can. It will be no different than if they accessed the string
via R.string.whatever.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.0.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ecthelion  
View profile  
 More options Dec 8 2010, 2:40 pm
From: Ecthelion <ep...@joergjahnke.de>
Date: Wed, 8 Dec 2010 11:40:06 -0800 (PST)
Local: Wed, Dec 8 2010 2:40 pm
Subject: Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error
On 8 Dez., 15:14, Mark Murphy <mmur...@commonsware.com> wrote:

> Sure you can. It will be no different than if they accessed the string
> via R.string.whatever.

Yes. And how would you know how the jar library is processing the
string if the code lies (obfuscated btw.) inside the library? I might
grep the library for all resource names with "%s %s" (or the like)
where I made changes. But if I should find one of these resource names
thereby, how will I know whether the code inside the library relies on
the old string format or whether it works fine with the new "%1$s
%2$s"?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Dec 8 2010, 2:52 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Wed, 8 Dec 2010 14:52:57 -0500
Local: Wed, Dec 8 2010 2:52 pm
Subject: Re: [android-developers] Re: SDK 2.3: Get "Multiple substitutions specified in non-positional format" error

On Wed, Dec 8, 2010 at 2:40 PM, Ecthelion <ep...@joergjahnke.de> wrote:
> Yes. And how would you know how the jar library is processing the
> string if the code lies (obfuscated btw.) inside the library? I might
> grep the library for all resource names with "%s %s" (or the like)
> where I made changes. But if I should find one of these resource names
> thereby, how will I know whether the code inside the library relies on
> the old string format or whether it works fine with the new "%1$s
> %2$s"?

Testing.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.0.1 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 40   Newer >
« Back to Discussions « Newer topic     Older topic »