收到一封google admob 寄來的信:
說要增加下面的code, 廣告在過了 2016-09-15 才會繼續放送:
apply plugin: ‘com.android.application’
…
dependencies {
compile ‘com.google.android.gms:play-
}
在加了上面的 code 進 gradle script 裡,發生了很多奇怪的錯誤。所以想說升級 gradle 到新的版本,原本是使用Android Stuiod 1.5 升級到 2.1.2.
gradle-wrapper.properties 也從原本的 gradle-2.2.1-all.zip 升到 gradle-2.10-all.zip.
之前的 gradle script:
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.0’
}
升級到:
dependencies {
classpath ‘com.android.tools.build:gradle:2.1.2’
}
為什麼要升級 gradle? 我也不知道,我發現別人的sample code 都升了,也跟著用新版本好了。
接著在console 裡有看到一些 warning 像是:
Some input files use or override a deprecated API.
一開始沒仔細看,以為紅字都是Error 為了解這個Warning 花了很多時間,後來發現是 Warning 就略過。
接著Build 失敗的問題是:
Error: The number of method references in a .dex file cannot exceed 64K.
為了解這個問題,花了一些時間,讀了些不錯的文章:
Configure Apps with Over 64K Methods
https://developer.android.com/studio/build/multidex.html
[Android Code] DEX with Over 65K Methods problem and how to use MultiDex on Android
http://www.akexorcist.com/2016/02/dex-with-over-65k-and-multidex-on-android-en.html
這篇真的寫的滿好的,圖文並茂,淺顯易懂,透過這篇也發現,Google 寄來的email 裡的 sample code 會造成 DEX with Over 65K Methods 的 error.
解法:
compile ‘com.google.android.gms:play-services-ads:9.2.0′
說明:真的不用import 整個 play services 那太胖了!
又解掉一個Build Error, 下一個Build Error 是:
“app_name” is not translated in “af” (Afrikaans), “am” (Amharic), “ar” (Arabic), “bg” (Bulgarian), “ca” (Catalan), “cs” (Czech), “da” (Danish), “de” (German), “el” (Greek), “en-rGB” (English: United Kingdom), “en-rIN” (English: India), “es” (Spanish), “es-rUS” (Spanish: United States), “et-rEE” (Estonian: Estonia), “fa” (Persian), “fi” (Finnish), “fr” (French), “fr-rCA” (French: Canada), “hi” (Hindi), “hr” (Croatian), “hu” (Hungarian), “hy-rAM” (Armenian: Armenia), “in” (Indonesian), “it” (Italian), “iw” (Hebrew), “ja” (Japanese), “ka-rGE” (Georgian: Georgia), “km-rKH” (Khmer: Cambodia), “ko” (Korean), “lo-rLA” (Lao: Lao People’s Democratic Republic), “lt” (Lithuanian), “lv” (Latvian), “mn-rMN” (Mongolian: Mongolia), “ms-rMY” (Malay: Malaysia), “nb” (Norwegian Bokmål), “nl” (Dutch), “pl” (Polish), “pt” (Portuguese), “pt-rPT” (Portuguese: Portugal), “ro” (Romanian), “ru” (Russian), “sk” (Slovak), “sl” (Slovene), “sr” (Serbian), “sv” (Swedish), “sw” (Swahili), “th” (Thai), “tl” (Tagalog), “tr” (Turkish), “uk” (Ukrainian), “vi” (Vietnamese), “zh-rCN” (Chinese: China), “zh-rHK” (Chinese: Hong Kong), “zh-rTW” (Chinese: Taiwan, Province of China), “zu” (Zulu)
之前使用 Android Stdio 1.5,可以直接Build,升級到 Android Studio 2.1.2,會跑出必需有完整對應的翻譯檔。解法是在strings.xml 裡增加 tools:ignore=”MissingTranslation” .
<?xml version=”1.0″ encoding=”utf-8″?>
<resources
xmlns:tools=”http://schemas.android.com/tools”
tools:ignore=”MissingTranslation”>
<string name=”app_name”>your app name</string>
</resources>
更多其他解法:
Android APP打包时,出错:”XXX” is not translated in “af” (Afrikaans), “am” (Amharic), “ar” (Arabic)…
http://blog.csdn.net/buaaroid/article/details/49469213