使用Android Studio生成签名APK时构建失败

3

当我尝试构建我的项目时,出现了这个错误:

    Error: "mail_subtitle" is translated here but not found in default locale [ExtraTranslation]
    Error: "login_subtitle" is translated here but not found in default locale [ExtraTranslation]
    Error: "password_subtitle" is translated here but not found in default locale [ExtraTranslation]
            ~~~~~~~~~~~~~~~~~~~~~
    /xxxxxx/src/main/res/values-es/strings.xml:336: Also translated here
   Explanation for issues of type "ExtraTranslation":
   If a string appears in a specific language translation file, but there is
   no corresponding string in the default locale, then this string is probably
   unused. (It's technically possible that your application is only intended
   to run in a specific locale, but it's still a good idea to provide a
   fallback.).
   Note that these strings can lead to crashes if the string is looked up on
   any locale not providing a translation, so it's important to clean them
   up.

  > 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
      }
  }
  ...

好的,我知道这个错误是因为我的字符串被翻译成了西班牙语和葡萄牙语,但是我没有默认的翻译。问题在于我的默认翻译在我的库中而不在此项目中。

整个项目的结构需要按照描述来进行:默认翻译在库内,其他翻译在此项目内。所有使用这些字符串的类都在库中,而翻译则在使用库的项目中,因为我需要为我正在构建的每个项目提供不同的翻译。

Android Studio建议使用lintOptions "abortOnError false",但我不想使用这个标志,我只想在发生构建错误时得到通知,我只是不想看到这个特定的错误。

1个回答

1
尝试将strings.xml添加到默认值文件夹中,例如/src/main/res/values/strings.xml?
然后在默认语言中添加3个缺失的字符串。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接