How to prevent Crashlytics from logging crashes during development in Android - android

While developing the app sometimes it crashes, and It's known crash while development, It unnecessarily sends mail to the client that some Trending stability issues in the app.
So I want to know if any method is there to stop logging while the development journey.

Crashlytics gives you the option to opt in or out from sending crash reports. You could use this in your code to prevent sending crash reports during development.
For this you could set the firebase_crashlytics_collection_enabled property in the AndroidManifest.xml file to false.
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
With this option you will can then re-enable Crashlytics data collection when running the release version:
if(!BuildConfig.DEBUG){
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
}
Or a similar option could be disabling Crashlytics data collection only when running the debug build. In this case, the the manifest property is not required.
if(BuildConfig.DEBUG){
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false);
}

you can disable uploading of mapping file and symbols in debug build:
buildTypes {
release {
firebaseCrashlytics {
mappingFileUploadEnabled true
nativeSymbolUploadEnabled true
}
}
debug {
firebaseCrashlytics {
// If you don't need crash reporting for your debug build,
// you can speed up your build by disabling mapping file uploading.
mappingFileUploadEnabled false
nativeSymbolUploadEnabled false
}
}
}
}

Related

Espresso-Web testing not working for release app

I am testing an app with UIAutomation tool provided by Android (https://developer.android.com/training/testing/other-components/ui-automator). It is working fine but not for some webviews . Then I started exploring the espresso-web (https://developer.android.com/training/testing/espresso/web ) library with the automator library and it is working for webviews in debug app but when I tried this in release app then it is not working and giving error message
android.support.test.espresso.NoActivityResumedException: No activities found ...
I tried finding out this error and most of the blogs says to use Activity Scenario OR Activity rule to initialise the app but My app is initialised through adb shell am start and for debug I am not getting this message and its working fine.
Please check two types of generate APK with release and build when build types debug is true then working in testing UI automation
buildTypes{
release{
debuggable false
}
debug
{
debuggable true
}
}

How to view Flutter app Dart stacktrace with Firebase Crashlytics?

I have a flutter app that uses some Android-specific code (Java/Kotlin). In "app/build.gradle" i do have firebaseCrashlytics/mappingFileUploadEnabled true:
release {
signingConfig signingConfigs.googleplaySigningConfig
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
firebaseCrashlytics {
mappingFileUploadEnabled true
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir "build/app/intermediates/merged_native_libs/release/out/lib"
}
ndk {
debugSymbolLevel 'FULL'
}
}
Also note in root "build.gradle":
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
I build the app using flutter build appbundle and i believe it should trigger uploading of obfuscation maps to Firebase crashlytics.
However i get smth like:
which makes me think Firebase Crashlytics was unable to find deobfuscated code for obfuscated using the uploaded mapping.
What can i do or check?
PS. After reading the error message more carefully i realized it's actually Dart code where the error happens (not my Java code). However, i'm still confused why i can't see Dart stacktrace instead.

Play console reports crashes that occur during development

I am seeing a lot of crashes and performance related issues in Google play console, Most of them are once that i faced during development.
I am also using crashlytics, and it has option to disable crashlytics during debugging, but i am unable to find out any option like this for Play Console Crash Reporting tool
Yes you can disable crashlytics it in debug mode.
Put it in your class which extends Application class in onCreate method
// Set up Crashlytics, disabled for debug builds
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
Fabric.with(this, crashlyticsKit);
To disable in playstore we can achieve it by differentiate the applicationId` in debug and release modes:
android {
...
defaultConfig {
applicationId "my.app.package"
...
}
...
buildTypes {
release {
...
}
debug {
...
applicationIdSuffix ".dev"
}
}
...
}
Note: This solution works when you are not using any libs, but it can break things up when using library that are configured with applicationId for example you use this approach if you are using billing app library may you no longer able to test in app billing in your app.

Disable Crashlytics Build Id automatic generation

I need to disable Crashlytics build_id automatic generation every time I assemble a new build because of CI requirements.
According to fabric docs, it's as simple as adding the next flag inside my build type:
android {
buildTypes {
debug {
ext.alwaysUpdateBuildId = false
...
}
release {
ext.alwaysUpdateBuildId = false
...
}
But for some reasons it's only working for debug builds and not on the release ones.
What am I doing wrong?
It's working fine in the latest version of Fabric Gradle plugin

Enable LogCat on Release Build in Android Studio

By default, when I change Build Variants to release I don't get any Logs on the logcat, but I do need to read release logs of my app, how can I enable this?
Add android:debuggable="true" (default is false) to your Manifest inside the <application> tag.
From the docs:
android:debuggable
Whether or not the application can be debugged,
even when running on a device in user mode — "true" if it can be, and
"false" if not.
respectively
You can disable debugging by removing the android:debuggable attribute
from the tag in your manifest file, or by setting the
android:debuggable attribute to false in your manifest file.
Edit
You may need to add the following to your build.gradle file inside the android{...} tag:
lintOptions {
checkReleaseBuilds false
}
And as a side-note: Right on the device the Logs are always written, no matter if your application's debuggable is set to false or true. But via the LogCat in Android Studio it's only possible if debuggable is set to true. (Just tested this)
You should add
android {
buildTypes {
release {
debuggable true
In this case you can use Log. or System.out.println and see logs.
If you cannot run release version (app is disabled), and error is shown: "apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog", see app-release-unsigned.apk is not signed.
I do not like the other solution because then you are not testing how the App really is deployed.
A better solution is to open the Android Device Monitor where you can see the logs even when in release configuration with debuggable=false.
Find it here:
Tools -> Android -> Android Device Monitor
Update:
Android Device Monitor was removed in Android Studio 3.2. However, it is still present in SDK, and you can use it to see the logs (it is located in $ANDROID_SDK/tools/)
debuggable true in build.gradle works well, except that BuildConfig.DEBUG is also going to be true. This might be a problem if your app relies on BuildConfig.DEBUG to do something only when it's a debug build.
In such a case, try Log.wtf(BuildConfig.APPLICATION_ID, "something went wrong"), which will print to logcat even if it's a release build.
This approach will obviously help you to get logs while testing the production build. But be careful while uploading your app to Google Play Store, Toggle debuggable to false before uploading to production.
buildTypes {
debug {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
lintOptions {
checkReleaseBuilds false
abortOnError false
}
shrinkResources true
minifyEnabled true
debuggable true
signingConfig signingConfigs.productionrelease
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
set crashlyticsCollectionEnabled to false to avoid your crashes to report to Google Play-Store while debugging.

Categories

Resources