本文介绍了错误:以非位置格式指定了多个替换;您是否要添加格式化的="false"?属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用,该应用会因以下错误而引发BUILD进程:

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/values.xml错误:(106,5)在非位置中指定了多个替换格式;您是否要添加格式化的="false"?属性?错误:(106,5)意外的结束标记字符串

/home/Ralf/Projekte/University/android-sampleapp/sampleapp/build/intermediates/bundles/debug/res/values/values.xmlError:(106, 5) Multiple substitutions specified in non-positionalformat; 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错误:(131)以非位置格式指定了多个替换;您是否要添加格式化的="false"?属性?错误:(131)意外的结束标记字符串

/home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug/values-de/values-de.xmlError:(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错误:(1258)在非位置中指定了多个替换格式;您是否要添加格式化的="false"?属性?错误:(1258)意外的结束标记字符串错误:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:执行时出错使用参数{package -f来处理/opt/sdk/build-tools/26.0.2/aapt--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}错误:com.android.ide.common.process.ProcessException:出现错误使用参数执行进程/opt/sdk/build-tools/26.0.2/aapt{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}错误:org.gradle.process.internal.ExecException:进程'command'/opt/sdk/build-tools/26.0.2/aapt'完成,非零退出值1

/home/Ralf/Projekte/University/android-sampleapp/demo/build/intermediates/res/merged/debug/values/values.xml Error:(1258) Multiple substitutions specified in non-positionalformat; did you mean to add the formatted="false" attribute?Error:(1258) Unexpected end tag stringError:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException: Error while executingprocess /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 whileexecuting 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 withnon-zero exit value 1

当我在字符串重新排序中单击错误时,它指向:隐藏%02d:%02d分钟

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

但是我需要翻译这些资源,为什么要得到这个?

推荐答案

这是因为您的String资源具有多个%s或类似的内容.为避免这种情况,您必须像这样标识每个:%1$s.示例:

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>

其中%1$s是您的第一个替换项,而%2$s是您的第二个替换项.

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

如果不打算执行任何替换,只需添加属性formatted="false".示例:

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>

这篇关于错误:以非位置格式指定了多个替换;您是否要添加格式化的="false"?属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:18