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

来源:互联网 发布:医药魔方数据百科 编辑:程序博客网 时间:2024/05/16 08:37

FROM:http://blog.csdn.net/qinyun188/article/details/7466973

在使用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下的文件中出现了没有多语言话的文本例如

<Button
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"
>
</Button>

解决办法:

res/values/strings.xml中定义字符串
<string name="led1on">on</string>

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

<Button
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"
>
</Button>

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


PS:在使用mmm编译的时候解决这类报错的方法是:

将对应xml里使用的字符串改用引用strings.xml里的tag就可以了, 

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

================================================================================================

This attribute must be localized.错误解决方式

FROM:https://www.oschina.net/question/163910_27978

eclipse中编译没有问题,但是在make自己建立的项目的时候,提示了错误“This attribute must be localized”,这种问题一般情况是因为在res/xml文件夹下的中或者在res/layout下的文件中出现了没有多语言话的文本例如 

<TextView    android:id="@+id/myTextView1"    android:text="type"    android:layout_width="fill_parent"></TextView>

解决方式:在res/values/strings.xml中定义字符串 
<string name="str_type">type</string>

然后把上面的内容改为 
<TextView    android:id="@+id/myTextView1"    android:text="@string/str_type"    android:layout_width="fill_parent"></TextView>

这是android强制实行多语言话 

阅读全文
0 0