I'm setting up Firebase Crashlytics for my Android app, and I would like the crash reports for the debug version to be separate from all other versions.
There are several copies of the auto-generated values.xml file (that is generated when the google-services plugin processes toe google-services.json file) located in the different retrospective buildType folders. One of the strings contained in the files is:
<string name="google_crash_reporting_api_key" translatable="false">{API-KEY}</string>
The API key is the same for each buildType, so I'm thinking if I can just create a new API key for the debug version, it'll solve the problem but how to do this? Or is there another way (that doesn't involve changing the applicationId as I can't do this)?
I've searched the android docs, looked up other articles and looked through other SO answers but no luck.
Any help welcomed, thank you.
You cannot differentiate the crash as per the build type (debug version).
You have to create a new project in the firebase with same app details (package name).
Get the API key for the project and then replace that key in your manifest file and DONE.
You just have to replace the key when you change your build Type.
Related
I know this has been asked already, but the problem persists for any version of com.google.gms:google-services above 4.2.0:
the searched location for my google-services.json file is no longer taking the flavour arborescence into consideration.
it only reads:
File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
~/app/google-services.json
instead of ~/app/src/TopflavorSubflavor/release/google-services.json
I have tried multiple permutations between the release folder and the flavor folder, even including Release in the flavor name, but nothing helps.
The official docs states it should work and that's why I am looking for something more than a workaround like creating the file in the /app/ folder at build time.
Try to name your flavors with underscore lowercase or one-word lowercase names :
top_flavor
subflavor
When running ./gradlew appDistributionUploadDevDebug I get an error saying it can't find the app.
The culprit is having applicationIdSuffix = ".dev" in my dev flavor. Removing it allows the apk to be uploaded, but then the artifact wouldn't be built properly. For the record I plan using only the dev flavor for internal distribution.
I get an error message saying I should enable app distribution, but since this is done on a "firebase project" level and it's done for the main flavor I can't do it again.
* What went wrong:
Execution failed for task ':app:appDistributionUploadDevDebug'.
> App Distribution could not find your app 1:xxxxxxxxx:android:0b3f<xxxxxxxxx>.
Make sure to onboard your app by pressing the "Get started" button on the App Distribution page in the Firebase console:
https://console.firebase.google.com/project/_/appdistribution
Documenting this as a bug, I'll add a reply since I found a workaround.
Edit: expanded name of gradlew task that was shortened. Though it works it may make for easier searching.
Workaround:
To fix open app/google-services.json and look for the mobilesdk_app_id key for the main package name.
For example in my case I noticed that 1:xxxxxxx:android:0b3f<xxxxxxx> was the value for the package with the .dev suffix, while the main package name (without .dev) shows under 1:xxxxxxx:android:7eb88<xxxxxxxx>
So heading to app/build.gradle, the firebaseAppDistribution block would look like this
firebaseAppDistribution {
appId = "1:xxxxxxxx:android:7eb88<xxxxxxxx>"
I still think this is a bug in firebase distribution. Sounds like the distribution gradle code is picking the right value, but the distribution server is not compatible.
BTW When the developer wants/needs to have 2 separate firebase projects you need to download 2 separate google-services.json files, and place them in the appropriate flavor folders. I also have a (2nd and 3rd) app that shares a project with that setup, but haven't added firebase distribution yet to check how it behaves.
For reference, my workaround worked while providing a serviceCredentialsFile. I also tried using the web token authentication but my results were inconclusive.
I thought that would be the case, but it turns out that you have to enable app distribution for each apk (buildType and/or flavor).
When selecting a project on the firebase console, the page automatically selects one of the apps and I was just enabling app distribution for that one.
There's a dropdown at the top where you can select another app (build/flavor), and you have to go to each one individually and enable app distribution.
I hope this helps someone else.
My Android app uses Google Payments and I store the API Keys in a values xml that is not added to VCS (used .gitignore file). I reference the value as R.string.api_licence from my code.
When I setup travis for CI, it was complaining that R.string.api_licence was not found. As a work around, I checked in a dummy text file with empty value for the key and rename the extension to xml from travis build script.
While this is working for now,
1 - This doesn't seem like a perfect solution
2 - Android Studio complains that the dummy txt file name should be of xml extension, and I have to delete it locally to work, which leads me to accidentally commit and break the builds sometimes
Travis script file: https://github.com/midhunhk/message-counter/blob/master/.travis.yml
Notes: I am a self taught Android developer. I don't require the real API keys to be used for CI process. I did some considerable research on this topic and couldn't get a specific answer to my problem.
I think the following approach can be used for solving this issue. I never got to test this as I changed my API implementation and may not need to store the API key in the source code.
https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.
I am trying to setup an Android app, using Android Studio with 2 different flavours. Each flavour changes packageName and applicationId - since I want 2 separate APK's submitted as 2 different products to Google Play.
I also try to setup separate apps in Crashlytics, one for each flavour. Although the first one was created without any problem, when I switch flavour, Crashlytics plugin for Android Studio still thinks that my project is already setup. So currently I cannot setup my Crashlytics for second flavour properly.
Thanks in advance for any suggestions.
As suggested by m4ch3t3 this workaround worked perfectly:
I created an empty project with package name matching the other
flavour. Using this project I created new app in Crashlytics. Then I
compiled both flavours of my real project and caused fake crashes in
them. Crashes were reported into matching Crashlytics apps
You can define different package name by definining applicationId in your app build.gradle as follow:
productFlavors {
dev {
applicationId "dev.myapp.app"
}
prod {
applicationId "prod.myapp.app"
}
}
Using the Crashlytics plugin for Android Studio will be a PITA in your case.
What you really need is only the API key and secret - shared among the same organisation - so if you already have one app correctly deployed on Crashlytics you can access those data from your organisation profile.
Just log out from the android studio plugin (CTRL+L while the plugin popup is focused), and take a look at this answer that explain how to deal with multiple flavour and multiple keys.