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?
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.
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:
in the folder .../android/res create a new language folder values-de (replace de with your language code).
create a file named google-services.xml in the language folder.
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.
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
}
}
...
you will probably have another bit of autogenerated code like this:
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Get a valid sender id from the google cloud console then you can remove the R.string.gcm_defaultSenderId from the above code and also the gcm_defaultSenderId from the resource file.
If you want/need upgrade to newer version of:
lint (androidstudio with build-in lint)
build tools
compileSdkVersion
gradle plugin
gradle
google-services (plugin)
google-services dedendencies (e.g. play-services-gcm)
(unfortunatelly) other dependencies if are transitivelly dependent to google-services
you need to choose wiselly versions of all these parts together. Since these all needs to be compatible together. Unfortunatelly, there is no compatibility table (the only I found is more a year old, so I do not link it here. If anybody know any please share a link).
So, solution is investigate which verstion of which part blocks anything else. Which could be nightmare, so a lot of advice is to revert to last known funcional configuration. But sooner or later we will be force to upgrade.
I checked home pages of each part to find any version info, but at last I still solve it by test-and-try method.
Here is what is functional for me:
androidstudio 1.5
build tools 23.0.2
compileSdkVersion 23
gradle plugin 1.5.0
gradle 2.8
google services plugin 1.5.0
google services dependencies 8.3.0
lucky, no other external GS dependencies (obviously all internal modules needs to use same version)
Related
Like many people, I am not able to add my application with Firebase Crashlytics.
I followed all the steps from the official documentation.
Also I previously checked and added my application to Firebase and everything is working fine.
My issue is the following:
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: null.
Check the Crashlytics plugin to make sure that the application has been added successfully!
Contact support#fabric.io for assistance.
I have the google-services.json file set correctly.. From the official documentation, it should works now without anything else to do..
Edit - Solution
Like I said in the comments, I found the issue. It's because of the Gradle version that I was using. I moved my project to support AndroidX and I was using the latest version 3.3+ but with this version the google-services.json file is not parsed during the build phase. It is resolved with the 3.2+ version.
From Firebase team, only stable version are working.
Is your project built to support instant apps (i.e. you have a base feature module, installable module, and instant app module)? I've been dealing with this exact error for the last day and a half, and what finally fixed it for me was adding crashlytics { instantAppSupport true } to the bottom of my gradle file for my base feature module. If you are built for instant apps, this might be worth a shot.
Are you sure you have added the Crashlytics API Key in one of these files?
AndroidManifest.xml:
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" />
Fabric Properties:
# Fabric properties file: app/fabric.properties
apiSecret=xxxxxxxxxxxxxxxxxxxxxxxxxxx
apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxx
I've used xwalk project in mine for a while now.
However, during the last round of library version upgrades, gradle doesn't like xwalk any more. Simply including it into my project
compile 'org.xwalk:xwalk_core_library:19.49.514.5'
will produce the following error on my dimens.xml:
error: resource android:attr/fontStyle not found.
error: resource android:attr/font not found.
error: resource android:attr/fontWeight not found.
dimens.xml:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
The conflicting attributes are actually referenced in app/build/intermediates/incremental/mergeDeployDebugResources/merged.dir/values/values.xml.
Initially I paid this no attention because I needed to develop some new functionality, but now it's time to publish and I need to make my "publish" flavor working again. The ONLY difference between gradle compiling or not being inclusion of xwalk into my project.
To make matters worse, I also upgraded Android Studio to version 3 and now I'm stuck not being able to revert my repository to something before the breaking change so that I could hunt for the issue.
I googled this a lot but it seems I'm the only one messing this up, so I'd appreciate any pointers on what I might be doing wrong.
Reverting xwalk version to an older one does not help. I'm currently using the latest version which still works on Android 4.0 (project requirement).
How can I fix this?
Edit: stupid me!!!
I didn't revert to OLD ENOUGH version of xwalk. reverting to 15.44.384.13 removes the problem.
The issue is that the attributes in question are only supported from API 16 forward and I must also work with 14 --> Even upping minSdkVersion to 16 doesn't solve the issue.
Edit2: disabling aapt2 does not help: the same errors are reported with aapt1.
Downgrading build tools from 26.0.2 to 25.0.2 does not help.
Edit3: Increasing compileSdkVersion & targetSdkVersion to 26 solves the problem. I have 22 normally because of Marshmallow permissions system. Note that it MUST be at least 26. Even 25 still produces the error.
I am allowed to leave it at 22 in the libraries I'm using, but not the main app project using xwalk.
Open build.gradle and put this at the end of the file:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Running "cordova build android" - unable to find attribute android:fontVariationSettings and android:ttcIndex
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.
Can anyone tell me why it is happening and How to Resolve these Errors ?
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.
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.
I am using google Maps in my android application. I have created the key and added necessary permissions in manifest file. But soon I start the application I get this message in debugger:
GoogleService failed to initialize, status: 10, Missing an expected
resource: 'R.string.google_app_id' for initializing Google services.
Possible causes are missing google-services.json or
com.google.gms.google-services gradle plugin.
I am not sure whats wrong. The Map is working fine and I can use it without any issues. My gradle file has this entry:
compile 'com.google.android.gms:play-services:8.4.0'
What is it complaining about and how do I alleviate it?
[From Product Manager # Google]
You can fix this issue by downloading and copying the google-services.json file for your Android app by following the steps below:
Select your app/project name and Android packagename from this link and click Continue to Choose and configure services.
Click Continue to Generate Configuration files.
Download google-services.json and copy the file to the app/ or mobile/ module directory in your Android project.
If you have previously imported your Google project into Firebase, you can
get the updated google-services.json from the Firebase console under Project Settings.
DO NOT COPY the PROJECT_NUMBER as suggested by one of the other answers since the google_app_id refers to your app within a Project and not the project itself.
You need to place the configuration file (google-services.json) generated by developer.google.com, as mentioned in the 2nd step of the official docs here
The process is simple
You can select your project or create a new one.
Then after selecting desired services (in this case the maps service), you can generate the configuration file.
For people who have migrated to the Firebase projects they can get the same by going to Firebase Console, selecting your project and under settings you will find the configuration file.
Then as quoted in step 3 of the official docs here
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android
P.S : For people downvoting this answer, please do leave a comment as to why you are down voting it.
In my case, the cause of this error was that the Google Services plugin for Gradle and the Play Services library were incompatible versions. Instructions for compatible versions:
1) Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
2) Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
3) If you're using Android Studio, this is the string to add to the dependency section of your application's build.gradle file:
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
Source: https://developers.google.com/cloud-messaging/android/client
I met the same problem and solved it followed the official solution.
Here are the steps:
get the configuration file google-services.json from this link.
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project.
Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Add this dependency to your app-level build.gradle:
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
For those who face this problem even after correctly setting up play services and placing google-services.json file in project/app folder, the actual solution is to
Build > Rebuild Project
Possibly due to the fact that strings from json file are not integrated into compiled resources until a full rebuild is performed.
For Xamarin/Visual Studio Mac I needed to add this to the bottom of my Droid.csproj
<Target Name="ProcessGoogleServicesJson" Condition=" '#(GoogleServicesJson)' != '' AND '$(AndroidApplication)' == 'True' AND '$(DesignTimeBuild)' != 'True'" BeforeTargets="$(ProcessGoogleServicesJsonBeforeTargets)" AfterTargets="$(ProcessGoogleServicesJsonAfterTargets)">
<Message Text="Using ProcessGoogleServicesJson override" Importance="high" />
<ProcessGoogleServicesJson GoogleServicesJsons="#(GoogleServicesJson)" IntermediateOutputPath="$(IntermediateOutputPath)" MonoAndroidResDirIntermediate="$(MonoAndroidResDirIntermediate)" AndroidPackageName="$(_AndroidPackage)">
<Output ItemName="_AndroidResourceDest" TaskParameter="GoogleServicesGeneratedResources" />
<Output ItemName="FileWrites" TaskParameter="GoogleServicesGeneratedResources" />
</ProcessGoogleServicesJson>
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)\ProcessGoogleServicesJson.stamp" />
</ItemGroup>
https://github.com/xamarin/GooglePlayServicesComponents/issues/64
This also happen to me. In my case, it is because Android studio tried to insert some code to my main activity. Removing the code fixes the error
Inserted code is about App Indexing:
https://developers.google.com/app-indexing/android/publish
I had the same issue back then. Was able to solve it by using only the necessary play services library, which in my case GCM.
Instead of com.google.android.gms:play-services:8.4.0, I use com.google.android.gms:play-services-gcm:8.4.0. See here for more info; this also solves multidex problem.
Then I applied both #Radix and #Alexander's approach to remove the message GCM has been output in the logcat regarding the google-services.json.
You can change the versionCode and versionName of your app in your Gradle file.
A quick fix I used is to disable signing. If you aren't wanting to create production code you can set your build variant to debug, localOldDebug or localDebug.
Click on Build Variants on the bottom left in Android Studio.
how-to-disable-generated-signed-apk-android-studio
Just have another solution i'm remove accidentally
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Add this and work, is for new solution
I'm new to Android Studio and i want to implement Urban Airship in one of my projects. I followed the example on their website with the .aar file and I ended up getting this error.
Error: [/Users/AndroidstudioProjects/MyApplication/app/build/intermediates/exploded-aar/com.urbanairship/urbanairship-lib/5.1.0/AndroidManifest.xml:8]
Invalid instruction 'overrideLibrary', valid instructions are : REMOVE,REPLACE,STRICT
Correct me if I'm wrong but doesn't this mean that they have issues in their manifest file? Or am I completely out in the blue? If so, do anyone have a good example on how to implement it?
The Urban Airship SDK builds against Google Play Services that requires Android API 9, while Urban Airship is compatible with 6+. That is why we need the override library version. What android gradle plugin version are you using? You need to use 13.3 or greater. See http://tools.android.com/tech-docs/new-build-system.
In the projects build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.+'
}
}
I just had the same problem, and was able to fix it and build my project:
The offending line is line 8 of the AndroidManifest.xml
I just removed this line and changed some SDK versions.
You can open the file urbanairship-lib-5.1.0.aar using WinRar.
Navigate to the Manifest. Open it and edit within your favourite text editor.
Save and close the manifest. WinRar asks if you want to update the archive. Choose Yes!
According to this page, overrideLibrary is used for when you have minSDK version in a library > minSDK version in your project. So it allows a different version to be compiled instead, without errors.
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:overrideLibrary-marker
Remove, replace etc do something a bit different (also described on that page - scroll up).
Then in my projects build.gradle file I changed the version numbers to match my project:
From this
compile 'com.android.support:support-v4:21.+'
To this
compile 'com.android.support:support-v4:19.+'
Would be good to know what's the outcome of the OP's support ticket. Please keep us posted!
I ran into this issue as well evaluating the 5.1.0 version of the Urban Airship SDK. I am using Android Studio Beta 0.8.14. I contacted Urban Airship support and they told me to increment the version of gradle to 0.13.3. Android Studio 0.8.14 is defaulting to 0.13.2. After changing the version of gradle to 0.13.3 in the project build.gradle file I was able to successfully compile and import the new SDK.