Error: This attribute must be localized. 解决方法

在使用mmm单独编译android应用程序时出现如下错误:

mmm packages/apps/BoardconLED/
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.4
TARGET_PRODUCT=idea6410
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRJ22
============================================
make: Entering directory `/home/cheyan/Android/6410/sbc6410_android2.3.4_20120315'
target R.java/Manifest.java: BoardconLedTest (out/target/common/obj/APPS/BoardconLedTest_intermediates/src/R.stamp)
res/layout/main.xml.bak:0: error: Resource entry main is already defined.
res/layout/main.xml:0: Originally defined here.
packages/apps/BoardconLED/res/values/strings.xml.bak:4: error: Resource entry app_name is already defined.
packages/apps/BoardconLED/res/values/strings.xml:3: Originally defined here.
packages/apps/BoardconLED/res/layout/main.xml.bak:8: error: Error: This attribute must be localized. (at 'text' with value 'on').
packages/apps/BoardconLED/res/layout/main.xml.bak:17: error: Error: This attribute must be localized. (at 'text' with value 'led1').
packages/apps/BoardconLED/res/layout/main.xml.bak:26: error: Error: This attribute must be localized. (at 'text' with value 'led2').
packages/apps/BoardconLED/res/layout/main.xml.bak:35: error: Error: This attribute must be localized. (at 'text' with value 'led3').
packages/apps/BoardconLED/res/layout/main.xml.bak:44: error: Error: This attribute must be localized. (at 'text' with value 'led4').
packages/apps/BoardconLED/res/layout/main.xml.bak:53: error: Error: This attribute must be localized. (at 'text' with value 'off').
packages/apps/BoardconLED/res/layout/main.xml.bak:62: error: Error: This attribute must be localized. (at 'text' with value 'on').
packages/apps/BoardconLED/res/layout/main.xml.bak:71: error: Error: This attribute must be localized. (at 'text' with value 'off').
packages/apps/BoardconLED/res/layout/main.xml.bak:80: error: Error: This attribute must be localized. (at 'text' with value 'on').
packages/apps/BoardconLED/res/layout/main.xml.bak:89: error: Error: This attribute must be localized. (at 'text' with value 'off').
packages/apps/BoardconLED/res/layout/main.xml.bak:98: error: Error: This attribute must be localized. (at 'text' with value 'on').
packages/apps/BoardconLED/res/layout/main.xml.bak:107: error: Error: This attribute must be localized. (at 'text' with value 'off').
packages/apps/BoardconLED/res/layout/main.xml.bak:116: error: Error: This attribute must be localized. (at 'text' with value 'All on').
packages/apps/BoardconLED/res/layout/main.xml.bak:125: error: Error: This attribute must be localized. (at 'text' with value 'All off').
make: *** [out/target/common/obj/APPS/BoardconLedTest_intermediates/src/R.stamp] Error 1
make: Leaving directory `/home/cheyan/Android/6410/sbc6410_android2.3.4_20120315'

“This attribute must be localized”,这种问题一般情况是因为在res/layout下的文件中出现了没有多语言话的文本例如

android:id="@+id/btnLED1On"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="on"
android:layout_x="8px"
android:layout_y="42px"
>

解决办法:

res/values/strings.xml中定义字符串
on

然后再把res/layout/main.xml相应内容改成

android:id="@+id/btnLED1On"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@sring/led1on"
android:layout_x="8px"
android:layout_y="42px"
>

这是android强制实行多语言话,是为了方便应用多言版本的扩充。

你可能感兴趣的:(android)