Android應用項目綁定appcom_v7打包時,出現錯誤:"XXX"isnottranslatedin"af"(Afrikaans),"am"(Amharic),"ar"(Arabic).....

來源:互聯網
上載者:User

標籤:

問題:當我們開發完成一個Android應用程式後,在發布該應用程式之前必須要經過的一步時打包應用程式。

至於從打包程式到發布的完整過程可以參考: Android 應用程式發布流程---碗豆莢發布流程

更新ADT至22.6.0版本之後,出現了這個庫,appcompat_v7是Google自己的一個相容包,就是一個支援庫,能讓2.1以上全使用上4.0版本的介面。例如使用ActionBar,不需要再使用第三方的支援庫了。

當項目綁定了Google官方提供的相容包appcompat_v7,打包項目時往往會遇到問題,如下所示:

選擇Eclipse ADT打包應用程式的過程如下:



可是在這時,會出現如下提示:

並且原本沒有錯誤的程式(values/strings.xml)也會出現如下錯誤提示:
[html] view plaincopy
  1. "app_name" is not translated in "af" (Afrikaans), "am" (Amharic), "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan),   
  2.  "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "en-rGB" (English: United Kingdom), "en-rIN" (English:   
  3.  India), "es" (Spanish), "es-rUS" (Spanish: United States), "et-rEE" (Estonian: Estonia), "fa" (Persian),   
  4.  "fi" (Finnish), "fr" (French), "fr-rCA" (French: Canada), "hi" (Hindi), "hr" (Croatian), "hu" (Hungarian), "hy-  
  5.  rAM" (Armenian: Armenia), "in" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ka-rGE" (Georgian:   
  6.  Georgia), "km-rKH" (Khmer: Cambodia), "ko" (Korean), "lo-rLA" (Lao: Lao People‘s Democratic Republic),   
  7.  "lt" (Lithuanian), "lv" (Latvian), "mn-rMN" (Mongolian: Mongolia), "ms-rMY" (Malay: Malaysia), "nb" (Norwegian   
  8.  Bokm?l), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "pt-rPT" (Portuguese: Portugal), "ro" (Romanian),   
  9.  "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sr" (Serbian), "sv" (Swedish), "sw" (Swahili), "th" (Thai),   
  10.  "tl" (Tagalog), "tr" (Turkish), "uk" (Ukrainian), "vi" (Vietnamese), "zh-rCN" (Chinese: China), "zh-rHK" (Chinese:   
  11.  Hong Kong), "zh-rTW" (Chinese: Taiwan, Province of China), "zu" (Zulu)  

是什麼原因呢?原因如下:
在Android SDK Tool r19之後, Export的時候遇到xxx is not translated in yyy, zzz的問題。
例如說"auto_name" is not translated in zh, zh_CN.
這是因為Android SDK Tool 將 ANDROID_LINT_COMPLETE_REGIONS 改為了需要檢查。
如何解決呢?

其實,以上提示已經給我們答案。一種是“fix these before running Export ”,另一種是“turn off ‘Run full error check when exporting app‘”
方法如下:
先說後者:“turn off ‘Run full error check when exporting app‘“
(1)在Eclipse中開啟Preference,按操作:

(2)再說前者:“fix these before running Export ”
操作如所示:

雙擊選擇4,會在5的左側出現對該問題的描述,如下:

框中也給我們三種解決方案。
即:
1》If the string should not be translated, you can add the attribute translatable="false" on the <string> element,

這種方法只適合數量較少的情況下。
2》字串數量較大的情況,會很麻煩,這時可以採用另一種方法:
or you can define all your non-translatable strings in a resource file called donottranslate.xml.
即我們可以將所有不需要non-translatable 的字串統一放入一個名叫donottranslate.xml的檔案中。
在values建立donottranslate.xml檔案,並把不需要non-translatable 的字串放入其中.
donottranslate.xml:
[html] view plaincopy
  1. <span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <string name="app_name">UMengDemo</string>  
  4.     <string name="action_settings" >Settings</string>  
  5.     <string name="sharePic_text" >分享本地圖片</string></span><pre name="code" class="html" style="text-indent: 0.10000000149011612px;"><span style="font-size:14px;"></resources></span>  


3》Or, you can ignore the issue with a tools:ignore="MissingTranslation" attribute.
第三種方法,就是用tools:ignore="MissingTranslation“ 屬性直接忽略這個問題
以上操作完成後,最好選擇“Clean”一下項目,方法如下:
 

這樣就可以解決以上問題了。

Android應用項目綁定appcom_v7打包時,出現錯誤:"XXX"isnottranslatedin"af"(Afrikaans),"am"(Amharic),"ar"(Arabic).....

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.