24

Recently I have Updated my Android Studio from 2.2.3 to 2.3.0 project was running fine in 2.2.3 but after updating project dependency classpath from 2.2.3 to 2.3.0 getting lots of Missing Translations error from string.xml.

enter image description here

Can anyone tell me why it is happening and How to Resolve these Errors ?

Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65

2 Answers2

50

Have many methods to fix this:

First method:

Add to build.gradle:

android {
     lintOptions {
        disable 'MissingTranslation'
    }
}

Second method:

It's the ignore attribute of the tools namespace in your strings file, as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources
  xmlns:tools="http://schemas.android.com/tools"
  tools:ignore="MissingTranslation" >

  <!-- your strings here; no need now for the translatable attribute -->

</resources>

Third method:

In your ADT go to window->Preferences->Android->Lint Error Checking

Find there Missing Translation and change its Severity to Warning.

Reference link:

http://www.fasteque.com/missingtranslation-issue-for-release-builds/

Hope it helpful for you.

Ave
  • 4,338
  • 4
  • 40
  • 67
14

I was facing the exact same issue. Based on my observation, this problem was introduced with Gradle plugin version 2.3.0. It occurs when there is a module in your project that supports more languages than your app or other modules. You could start editing the translations of such modules but that makes them less maintainable.

If you disable the Lint checks using any of the suggestions here or for similar questions you also ignore actual translation errors in your app where a translation is missing for a language you are supporting. You need to be very careful maintaining your strings after that.

There is one more, also suboptimal, option: change the plugin version back to the last one not showing these symptoms in your build.gradle.

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
}

There is however a way to make this work without losing vital warnings/errors and without reverting to old tool versions. You can find it in Google's documentation and also in this answer.

android {
    defaultConfig {
        ...
        resConfigs "en", "fr"
    }
}

This removes not needed resources and the warnings and errors along with them. I have updated my code and it builds fine now.

There is another issue that was introduced with the new Gradle plugin version: If you get false positives, i.e. errors complaining about missing translations for a string you have marked non-translatable, check if the string name exists in another module. In that case rename or provide the translations and the error disappears.

  • This worked and seems to be the clean appropriate solution `resConfigs "en", "fr"` – Riz Sep 21 '17 at 16:04
  • Using "resConfigs" actually changes how your APK is built, For the risk-adverse, consider if you want to change that to remove an IDE warning. – Jeffrey Blattman Feb 02 '21 at 18:44
  • Hmm. Could you elaborate on what the risk is? My understanding is that this is exactly what it is intended for, i.e. strip out the unwanted languages, which not only cause IDE warnings (many in some cases) but possibly also languages unsupported by the app to show. –  Feb 02 '21 at 20:54