Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't generate APK Release because of GCM SenderId Android

I have implemented GCM (Google Cloud Messaging) in my app. Google Play Services library has auto-generated values.xml in which my senderId is :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="gcm_defaultSenderId">123</string>
</resources>

The problem is that I have other locale, and Lint during App Release is giving me an error : Error:(3) Error: "gcm_defaultSenderId" is not translated in "fr" (French) [MissingTranslation]

Because it is automaticaly generated I can't set translable = false. How I should fix this?

like image 722
filipp.kowalski Avatar asked Sep 04 '15 16:09

filipp.kowalski


3 Answers

Add a lint.xml file in your project application root (under app/) and add the missing translations to be ignored there:

<lint>
    <issue id="MissingTranslation">
        <ignore regexp="ga_trackingId"/>
        <ignore regexp="gcm_defaultSenderId"/>
        <ignore regexp="google_app_id"/>
    </issue>
</lint>

These will now be ignored by lint - you can configure which properties to ignore, and you won't have to wait for updates from the google-services team for properties that they haven't thought of.

Lint-ing will still catch all other errors, so you can still enjoy the other features.

like image 57
MatsLindh Avatar answered Oct 06 '22 04:10

MatsLindh


I assume that you are using Android Studio.

Had the exact same problem with Android Studio 1.4.

First thing I tried was to edit the "File - Settings - Editor - Inspections - Android Lint - Incomplete Translation" Severity Setting to something other then 'Error'.

That did not help! I still was not able to build a release APK.

I ended up 'translating' the XML as follows:

  1. in the folder .../android/res create a new language folder values-de (replace de with your language code).

  2. create a file named google-services.xml in the language folder.

  3. Insert into the xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <string name="gcm_defaultSenderId"><YOUR_SENDERID></string>
    </resources>
    

    After that I was able to build the release.

like image 39
Andre Kreienbring Avatar answered Oct 06 '22 04:10

Andre Kreienbring


Since the last update of Android Studio (1.5) I had this issue too. I solved it by updating the Google Services dependencies to the latest version.

According to this link, indeed,

This issue should be fixed with 8.3.0 Google Play Services and 1.5.0-beta2 dependency.

Hope this helps! :)


EDIT Integration: actually, while the gcm_defaultSenderId string is now generated correctly (with translatable="false" attribute), google_app_id and ga_trackingID strings, for instance, are not.

For those still having issues, I came to the conclusion that we have to wait for Google guys to fix this issue and ignore the error in the meantime by adding to the app level build.gradle file

...
android {
    lintOptions {
        abortOnError false
    }
}
...
like image 28
Cristina De Rito Avatar answered Oct 06 '22 06:10

Cristina De Rito