AndroidStudio 打包报错 - is not translated和is translated here but not found in default locale

AndroidStudio 打包报错

  1. ”xxx“ is not translated in ”yyy“, ”zzz“

  2. “ xxx” is translated here but not found in default locale
    [ExtraTranslation]

问题一:

”xxx“ is not translated in ”yyy“, ”zzz“

原因:

Android Studio在打包的过程中在Android SDK Tool r19之后, Export的时候遇到xxx is not translated in yyy, zzz的问题。

解决方案

1、在报错的gradle文件中添加:

android {
    lintOptions {
       disable 'MissingTranslation'
    }
 }

2、
(1)如果是只有少量的字段报错
在String里面添加translatable=”false”

<string name="finish" translatable="false">完成</string>

(2)如果是有大量的字段报错需要修改
在资源里(报错的strings文件)添加tools:ignore=”MissingTranslation”(如果之前没导入tools包,这里复制进去是需要导包的)

<resources tools:ignore="MissingTranslation" xmlns:tools="http://schemas.android.com/tools">

**

这里,建议选择第一种方案,通常会有不少文件报错,第一种比较解决根本

**

问题二

“ xxx” is translated here but not found in default locale

原因

在默认的strings.xml里没有这个字段

解决方案

和第一个问题一样的办法,只是稍有不同

lintOptions {
     disable 'ExtraTranslation'
    }
<resources tools:ignore="ExtraTranslation" xmlns:tools="http://schemas.android.com/tools">

推荐方案,这两个问题一并解决

lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
    }

在报错的文件所在build.gradle文件中添加上面代码即可

猜你喜欢

转载自blog.csdn.net/qq55214/article/details/72315662