Firebase crashlytics mapping file upload doesn't work - android

I have added firebase crashlytics lib and crashlytics gradle plugin to my project
classpath("com.google.firebase:firebase-crashlytics-gradle:2.3.0")
...
plugins {
...
id("com.google.firebase.crashlytics")
...
}
...
implementation("com.google.firebase:firebase-crashlytics:17.2.1")
implementation("com.google.firebase:firebase-analytics:17.5.0")
I explicitly set mappingFileUploadEnabled for my release build types with
getByName("release").apply {
firebaseCrashlytics.mappingFileUploadEnabled = true
}
But mapping file is unfortunately not uploaded. I verify it in firebase crashlytics console - for my test crashes stacktrace points to Unknown Source:55.
Here is what I found in gradle logs:
[DEBUG] [com.google.firebase.crashlytics] Mapping File Upload Enabled: false; id: 00000000000000000000000000000000
So it seems my mappingFileUploadEnabled flag has no effect.
Do I need to do something else to make mapping file upload work?
I also don't see firebaseUpload*ReleaseProguardMapping tasks in my project. Not sure if it is supposed to be created though.
UPDATE
I have tried to create an empty android project from scratch and added firebase-crashlytics there. There it seems to work and I can see uploadCrashlyticsMappingFile tasks created for all build types. So for now it looks like firebase-crashlytics gradle plugin doesn't work correctly for my project and doesn't create tasks it is supposed to create. Does anyone have an idea why?

Today I learned that if you apply firebase-crashlytics gradle plugin declaratively, using the plugins {} block the mapping file upload tasks are not created. In order to make it work I had to apply the plugin imperatively using the legacy apply(..) function. This is what I have in the project now:
apply(plugin = "com.google.firebase.crashlytics")
plugins {
//other plugins
}
After making this change the mapping file upload works fine.
UPDATE
I figured out that if I move crashlytics plugin to the bottom on my plugins section I have the same effect.
Now it looks like:
plugins {
//all other plugins
id("com.google.firebase.crashlytics")
}

Related

firebaseAppDistribution with Github Actions throwing error "Missing app id", even with google services plugin set

I'm implementing app distribution for android with github actions, everything seems to be okay but I'm getting an error:
* What went wrong:
Execution failed for task ':app:appDistributionUploadQaRelease'.
> Missing app id. Please check that it was passed in and try again
I'm using google play plugin so it should get the app id automatically.
https://firebase.google.com/docs/app-distribution/android/distribute-gradle#step_3_configure_your_distribution_properties
appId -- Your app's Firebase App ID. Required only if you don't have the Google Services Gradle plugin installed.
I have google-services.json file in app module,
in root build.gradle:
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.0'
in app's build.gradle:
plugins {
....
id 'com.google.gms.google-services'
id 'com.google.firebase.appdistribution'
}
in qa flavour:
productFlavors {
....
qa {
applicationId "custom.package.for.qa"
....
firebaseAppDistribution {
releaseNotes = "something 123"
groups = "testers"
}
}
}
if I add "appId = ...." inside firebaseAppDistribution, the build is uploaded successfully. but this shouldn't be necessary because of google play plugin.
and in github action:
- name: Build & Deploy
run: |
export FIREBASE_TOKEN=${{ secrets.FIREBASE_TOKEN }}
./gradlew --stop
./gradlew clean
./gradlew assembleQaRelease appDistributionUploadQaRelease
Thanks!
I also confirm it's a bug in the latest version of their library:
com.google.firebase:firebase-appdistribution-gradle:3.0.0
I opened an issue on their GitHub so hopefully they will fix it soon.
It's a bug in 3.0.0 which fails in some cases.
So temporarily downgrade to: com.google.firebase:firebase-appdistribution-gradle:2.2.0
I had the same issue with 3.0.0 but on Bitbucket pipelines using Service account for upload. Same build just with updated to 3.0.0 fails, with 2.2.0 is Ok.
Because Google don't provide Changelog for Firebase app distribution, we can't validate if they change something in configuration. It looks, that App distribution stops searching for AppId in google-services.json file.
Reply from Google:
I just received feedback from our engineering team. Our investigation
confirms that this is a bug, and because of this, we apologize for the
impact that this may have caused during your distribution process.
They're working on rolling out a fix for this issue, but this will
most likely be available in a newer version of the SDK. We won't be
able to share any timelines at the moment that would confirm exactly
when this bug will be fixed. For now, you can regularly check for
updates on our release notes, or from the main issue thread in GitHub.
I got a reply from firebase support, unfortunately it DOES NOT work for me still, but he was able to reproduce the issue and then resolved it by doing the following, hopefully it will fix it for someone else :
Add the Firebase SDK plugins in your build.gradle (project) file. See Figure 1.0.
Apply the Firebase SDK plugins in your build.gradle (app) file. See Figure 2.0.
Make sure that you have a google-services.json file in your app folder.
Rebuild and Upload your APK to Firebase App Distribution using the commands below:
In a terminal window, run gradlew assembleDebug.
In a terminal window, run gradlew appDistributionUploadDebug.
Figure 1.0 - build.gradle (project)
buildscript {
// …
dependencies {
// Firebase SDK - Plugins
classpath 'com.google.gms:google-services:4.3.10' // Google Services
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.0' // App Distribution
}
}
Figure 2.0 - build.gradle (app)
plugins {
// …
id 'com.google.gms.google-services' // Google Services
id 'com.google.firebase.appdistribution' // App Distribution
}
android {
// …
buildTypes {
debug {
firebaseAppDistribution {
artifactType="APK"
releaseNotes="..."
testers="..#gmail.com"
}
}
}
// …
}
dependencies {
// …
implementation platform('com.google.firebase:firebase-bom:29.0.4') // bom
implementation 'com.google.firebase:firebase-analytics-ktx' // analytics
}
I have my project set to exactly this, but for some reason github actions still fails with missing id.
Adding the google-services plugin worked for me. I'm using the firebase-appdistribution-gradle:3.0.1

How to get rid of Kotlin DSL warnings

I have just started learning KotlinDSL recently.
And in Android added buildSrc. In this folder I have module plugins: AppModulePlugin, CommonModulePlugin, FeatureModulePlugin. All of this compiles and the application installs correctly, everything is fine. but in these files a warning is displayed:
Cannot access 'com.android.build.gradle.internal.dsl.Lockable'
which is a supertype of 'com.android.build.gradle.BaseExtension'.
Check your module classpath for missing or conflicting dependencies
Please tell me how to get rid of these warnings?
IntelliJ has had this issue for months unfortunately - it reports correct code as invalid. See KTIJ-3769. I believe it's dependent on ticket KTIJ-19669.
As a workaround you can either replace the helper methods that the plugins introduce with 'plain' Gradle Kotlin
// androidExtension { }
project.extensions.configure<BaseExtension> {
}
Or only create buildSrc plugins in Kotlin (*.kt files), not Kotlin Script (*.kts files). This requires using the java-gradle-plugin and defining the plugins in buildSrc/build.gradle.kts.

Error when executing crashlyticsGenerateSymbols task with android gradle plugin 3.6+

Where do i report this error? or could anyone help me?
“Directory X specified for property ‘$2’ does not exist” error when executing crashlyticsGenerateSymbols task
with
android gradle plugin 3.6.0
gradle version 5.6.4
fabric gradle plugin 1.31.2
[Error logs]
Some problems were found with the configuration of task ':~~~~~:crashlyticsGenerateSymbolsRelease' (type 'DefaultTask').
Directory '~~~' specified for property '$1' does not exist.
Directory '~~~~' specified for property '$2' does not exist.
Fabric/Firebaser here. This error comes up when the Fabric Gradle plugin is trying to parse your project structure in order to find your stripped and unstripped binaries, and is unable to do so. When it asks for properties $1 and $2 it means it could not find the default paths to the "obj" and "libs" folders that contain your supported ABIs folders with your supported native libraries there.
Using the legacy Fabric Gradle plugin, you can specify these paths under your crashlytics block in the build.gradle, like so:
crashlytics {
enableNdk true
androidNdkOut 'obj'
androidNdkLibsOut 'libs'
}
In the case for builds that are on Android Studio 3.5 or later, you can usually find the paths for these somewhere in the outputted build folders under "merged_native_libs" and "stripped_native_libs."
If you're using the new Firebase Crashlytics SDKs and Gradle plugin, those paths are controlled by "strippedNativeLibsDir" and "unstrippedNativeLibsDir" flags in the firebaseCrashlytics block in your build.gradle.
If you continue running into problems feel free to file a case with Firebase support with more details about your project and what you've tried to configure so far, and you can also still reach out to support#fabric.io.
I got the same issue on my side, and I fixed it by removing ext.enableCrashlytics = false from my app-level build.gradle in
android {
buildTypes {
debug {
// ext.enableCrashlytics = false
}
}
}

Jitpack builds successfuly, but jars are empty for every module

In recent release of our library we decided to add some kotlin-dsl features to our build, though for now we've added buildSrc build.gradle.kts and Dependencies.kts file containing libraries versions for easier use across all modules.
The problem is that this version builds successfuly on jitpack, but downloaded jars are empty. How do I fix this? Also all the resource files are present. The build log file also differs much from previous ones.
Problematic build log file
Working build log file
A link to library on jitpack: https://jitpack.io/#netigenkluzowicz/api_android
Github link
branch to reproduce these build problems is feature/kotlin, we're working to fix it on fix/jitpack-build branch
To Reproduce
Add this dependency to an Android project, sync and check classes.jars
implementation 'com.github.netigenkluzowicz:api_android:2.4.1'
What we did before this problem started to occur:
Added buildSrc directory with build.gradle.kts and Dependencies.kts.
We also extracted android { } block from our modules build.gradle files, it is now applied from android.gradle file.
I've already went through jitpack issues on github, all I found so far are build errors with kotlin-dsl from late 2018. Was following this guide to make a use of kotlin-dsl, though due to having issues with android { } block I didn't migrate all of our gradle files.

Android Marshmallow error:GoogleService failed to initialize, status: 10, Missing an expected resource: [duplicate]

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

Categories

Resources