6

The problem is odd. I'm trying to add a String directly in build.gradle because I need it to use Tray library (https://github.com/grandcentrix/tray). In my first project everything went fine. In the second project it's a little bit more complicated. I'm using gradle:1.2.3 and while exporting signed apk there is a MissingTranslation error.

build.gradle

applicationId "some.app.id"
resValue "string", "tray__authority", "${applicationId}.tray"

build error

.../build/generated/res/generated/release/values/generated.xml
Error:(7) Error: "tray__authority" is not translated in "pl" (Polish) [MissingTranslation]
<string name="tray__authority">some.app.id.tray</string>

generated.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- Automatically generated file. DO NOT MODIFY -->

    <!-- Values from default config. -->
    <string name="tray__authority">some.app.id.tray</string>

</resources>

There are a few similar questions but all of them are related to strings.xml and it's suggested to

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

or just translatable="false"

I cannot do it because the file is auto-generated. How can I force gradle to ignore the error? I tried to change inspection settings and make it a warning but gradle is ignoring my settings.

I know it's a bug (https://code.google.com/p/android/issues/detail?id=152198) but I don't know how to resolve it. All the answers I found don't work.

2
  • That's a lint error, which prevents you from building the app when it shouldn't, if it's your choice not to support certain strings in Polish. You can disable individual lint checks in Android Studio or Eclipse, set this check to "ignore" and it won't complain.
    – Christine
    Commented Jul 10, 2015 at 22:43
  • But the latest gradle ignores the setting :( I'm talking about building a production version by gradlew
    – koras
    Commented Jul 11, 2015 at 0:47

2 Answers 2

11

Well, I solved this. It has to be said that the error is strange. It never appeared before, only the latest gradle version has the problem. I found out that generating a signed apk ignores our inspection settings (Android Studio) and it's impossible to generate a production release.

Just ignore it in the right place! Here: build.gradle

android {
    // defaultConfig, buildTypes, etc.

    lintOptions {
        disable 'MissingTranslation'
    }
}

The solution should be used with awareness that all the missing translations will be just ignored so I recommend to comment it, double check what is missing and finally uncomment it when everything is as intended ;)

I hope it helped somebody. Very annoying thing.

1
  • It's strange. I use minify in all my apps and everything is OK. Try to upgrade gradle (specify the latest version in your build config, eg. 1.5). It may help.
    – koras
    Commented Jan 28, 2016 at 16:22
1

In Android Studio, go to Settings/Inspections/Android lint, in the search box type "missingtranslation", then select "info" instead of "error" on the lower right. Or uncheck the thing altogether.

2
  • I know that. But gradle build (release) seems to ignore it and the app still doesn't build. I changed it to info. I will try to disable it completely.
    – koras
    Commented Jul 11, 2015 at 0:29
  • Even disabling the value is ignored by gradle. Lol... There's a bug somewhere. Previous gradle versions didn't even need to change something to ignore strings from build.gradle
    – koras
    Commented Jul 11, 2015 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.