Studio编译Lint found fatal errors while assembling a release target.错误

问题描述

在使用studio编译release版本时,遇到了下面的问题【编译debug问题不会遇到】:

Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:...

android {

    lintOptions {

    checkReleaseBuilds false

    // Or, if you prefer, you can continue to check for errors in release builds,

    // but continue the build even when errors are found:

    abortOnError false

     }

}

    ...

解决方法一:

大部分人看了上面的信息,都会按照提示,找到build.gradle默默添加一行:

lintOptions {    checkReleaseBuilds false    // Or, if you prefer, you can continue to check for errors in release builds,    // but continue the build even when errors are found:    abortOnError false     }

重新编译,问题解决,似乎没毛病。但是解决完让然一脸懵逼,我很想知道我究竟错在哪里,继续探究下去,有了解决方法二

解决方法二:

原来这个出错报告会放在[app module]/build/reports/lint-results-release-fatal.html里面,用浏览器打开,它长这样子:

我的理解就是开启了翻译检查,那怎样修改呢,我们打开这个出错的文件string.xml,将鼠标放在出错的条目可以看到提示:

"navigation_title_setting" is not translated in "de" (German), "hi" (Hindi), "lo" (Lao), "pt" (Portuguese), "lt" (Lithuanian), "hr" (Croatian), "lv" (Latvian), "hu" (Hungarian), "hy" (Armenian), "uk" (Ukrainian), "ur" (Urdu), "mk" (Macedonian), "ml" (Malayalam), "mn" (Mongolian), "af" (Afrikaans), "mr" (Marathi), "uz" (Uzbek), "ms" (Malay), "el" (Greek), "en" (English), "is" (Icelandic), "it" (Italian), "am" (Amharic), "my" (Burmese), "es" (Spanish), "iw" (Hebrew), "zh" (Chinese), "et" (Estonian), "eu" (Basque), "ar" (Arabic), "vi" (Vietnamese), "nb" (Norwegian Bokmål), "ja" (Japanese), "ne" (Nepali), "az" (Azerbaijani), "fa" (Persian), "zu" (Zulu), "ro" (Romanian), "nl" (Dutch), "be" (Belarusian), "fi" (Finnish), "ru" (Russian), "bg" (Bulgarian), "bn" (Bengali), "fr" (French), "bs" (Bosnian), "ka" (Georgian), "si" (Sinhala), "sk" (Slovak), "sl" (Slovenian), "ca" (Catalan), "sq" (Albanian), "sr" (Serbian), "kk" (Kazakh), "km" (Khmer), "kn" (Kannada), "sv" (Swedish), "ko" (Korean), "sw" (Swahili), "gl" (Galician), "ta" (Tamil), "gu" (Gujarati), "ky" (Kyrgyz), "cs" (Czech), "pa" (Punjabi), "te" (Telugu), "th" (Thai), "tl" (Tagalog), "pl" (Polish), "da" (Danish), "tr" (Turkish) less... (Ctrl+F1) If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages. If the string should not be translated, you can add the attribute translatable="false" on the <string> element, or you can define all your non-translatable strings in a resource file called donottranslate.xml. Or, you can ignore the issue with a tools:ignore="MissingTranslation" attribute. You can tell lint (and other tools) which language is the default language in your res/values/ folder by specifying tools:locale="languageCode" for the root <resources> element in your resource file. (The tools prefix refers to the namespace declaration http://schemas.android.com/tools.) Issue id: MissingTranslation

第一种如果你的app支持多语言,你还是要重视一下这个提示,如果暂时不想管,可以将错误的条目都加上 attribute translatable="false"属性,这样每个错误的都要加

第二种建立donottranslate.xml,将不用翻译的全部放入此文件

第三种忽视提醒,加上tools:ignore="MissingTranslation"属性,我选择这种,修改如下:

修改完毕,重新编译不报错!