Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

I have an Android app, which throws on BUILD process following error:

/home/Ralf/Projekte/University/android-sampleapp/sampleapp/build/intermediates/bundles/debug/res/values-de/values-de.xml Error:(88, 5) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(88, 5) Unexpected end tag string

/home/Ralf/Projekte/University/android-sampleapp/sampleapp/build/intermediates/bundles/debug/res/values/values.xml Error:(106, 5) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(106, 5) Unexpected end tag string

/home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug/values-de/values-de.xml Error:(131) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(131) Unexpected end tag string

/home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug/values/values.xml Error:(1258) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(1258) Unexpected end tag string Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /opt/sdk/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /opt/sdk/platforms/android-27/android.jar -M /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug -m -J /home/Ralf/Projekte/University/android-sampleapp/demo/build/generated/source/r/debug -F /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/debug/resources-debug.ap_ -D /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.ralfi.demo -0 apk --output-text-symbols /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/symbols/debug --no-version-vectors} Error:com.android.ide.common.process.ProcessException: Error while executing process /opt/sdk/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /opt/sdk/platforms/android-27/android.jar -M /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug -m -J /home/Ralf/Projekte/University/android-sampleapp/demo/build/generated/source/r/debug -F /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/debug/resources-debug.ap_ -D /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.ralfi.demo -0 apk --output-text-symbols /home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/symbols/debug --no-version-vectors} Error:org.gradle.process.internal.ExecException: Process 'command '/opt/sdk/build-tools/26.0.2/aapt'' finished with non-zero exit value 1

When I click on the errors at the string resrouces, it points to: Hide for %02d:%02d min

But I need a translation for those resources, why am I getting this?

like image 422
Ralf Wickum Avatar asked Jan 19 '18 16:01

Ralf Wickum


2 Answers

That is because your String resource has multiple %s or similar. To avoid this, you must identify each like this: %1$s. Example:

<string name="full_name">First: %1$s - Last: %2$s</string>

Where %1$s is your first substitution and %2$s is your second.

If you do not mean to perform any substitution, just add the attribute formatted="false". Example:

<string name="your_string" formatted="false">Level: 100%</string>

like image 113
Lucas De Morais Cabrales Avatar answered Sep 23 '22 15:09

Lucas De Morais Cabrales


Another possibility for this error when it has been a warning previously; There can be a different error hidden among these errors so you need to go find and fix that. There was a duplicate resource value error and somehow that trigger a lot of the 'Multiple substitutions specified in non-positional format' for me and finding and fixing the duplicate value error resolved the build problem.

like image 37
Alan Avatar answered Sep 20 '22 15:09

Alan