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

一世执手 提交于 2020-05-12 11:09:12

问题


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?


回答1:


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>



来源:https://stackoverflow.com/questions/48345910/error-multiple-substitutions-specified-in-non-positional-format-did-you-mean-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!