美文网首页
Android Studio 打包时的注意事项

Android Studio 打包时的注意事项

作者: 小小卒_oO_ | 来源:发表于2019-03-11 10:12 被阅读0次

用R.string存储些常量,打包时Android Studio走了translate in english的路线。所以报错如下:
string value is not translated in "zh"(Chinese)[MissingTranslation]

3种处理办法:

1.在project的build.gradle的android{}中添加
lintOptions {
        checkReleaseBuilds false //在打包Release版本的时候进行检测
        abortOnError false //设为false,这样即使有报错也不会停止打包了
        disable 'MissingTranslation' //仅把translate引起的warning屏蔽掉,不要妨碍APK的生成
    }
2.直接在string.xml文件内的resources添加ignore
<resources
   xmlns:tools="http://schemas.android.com/tools"
   tools:ignore="MissingTranslation">
    <string name="hello_world">你好</string>
</resources>
3.针对某几个字符串,在string 里加translatable="false"
<string name="hello_world" translatable="false">你好</string>

相关文章

网友评论

      本文标题:Android Studio 打包时的注意事项

      本文链接:https://www.haomeiwen.com/subject/emcdpqtx.html