Play console reports crashes that occur during development - android

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.

Related

How to prevent Crashlytics from logging crashes during development in 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
}
}
}
}

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
}
}

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

Can I enable multidex in Android debug build only?

Dears,
I read in many blog posts that multidex apps startup is slower than normal apps.
My app uses a lot of libraries that exceed 64k methods so I use multidex. But when I use proguard in release build, the final apk becomes less than 64k methods
So My question is: Can I enable multidex in Android debug build only so I don't have runtime error? and disable multi dex in release build as I don't need it?
If yes, how ?
If No, Is Android smart enough to speedup startup as it should recognize that app didn't exceed 64k even if it is multi dex app ?
Yes, you can. When you declare your buildTypes include multidex only for debug:
buildTypes {
release {
multiDexEnabled false
    }
debug {
multiDexEnabled true
}
}
Instead of enabling multidex only for debug, you can change your min sdk version to 21 only for debug so gradle can speed up dexing with ART:
android {
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 14
}
}
...
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
http://developer.android.com/tools/building/multidex.html
suggested methods are not needed anymore as android studio became "smart enough".
In fact, it will now give you a warning when you use minSdkVersion 21 (the old way) to speed up build time with dex:
You no longer need a dev mode to enable multi-dexing during
development, and this can break API version checks less...
In the past, our documentation recommended creating a dev product
flavor with has a minSdkVersion of 21, in order to enable multidexing
to speed up builds significantly during development. That workaround
is no longer necessary, and it has some serious downsides, such as
breaking API access checking (since the true minSdkVersion is no
longer known.) In recent versions of the IDE and the Gradle plugin,
the IDE automatically passes the API level of the connected device
used for deployment, and if that device is at least API 21, then
multidexing is automatically turned on, meaning that you get the same
speed benefits as the dev product flavor but without the downsides.
Yes, it even works with the multidex support library for Android versions prior to Lollipop with a little trick.
First specify multiDexEnabled for the debug build in build.gradle:
buildTypes {
...
debug {
...
multiDexEnabled true
}
}
Then create an AndroidManifest.xml file under src/debug.
src/debug/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name="android.support.multidex.MultiDexApplication"
tools:replace="android:name"/>
</manifest>
That should do the trick. If your app uses a custom application class then you have to create a subclass of your application class and specify the name of that subclass in the manifest.
The application subclass should look like this:
public class MyDebugApplication extends MyApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

how to manage debug and release version on android device?

I'm new to Android dev and I'm almost ready to release a first version of my app :)
While testing the signed release apk on my phone, it refuse to install because the debug version is installed with the debug signature.
So I have to uninstall the debug version but it delete all my database (and it will do it to my friends who are testing it).
Is there a way to manage a debug and a release version of the same app without losing data?
Many Android projects are starting to use the gradle build system (we transitioned to it when we started using Android Studio). Fortunately, gradle makes it really simple to install both a dev and release version simultaneously, each with their own independent data. The Android docs cover this, just add a applicationIdSuffix to your debug build type like so:
android {
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
}
I'm not aware of any easy way to do get around the uninstall/reinstall process, so your options include...
Buy a second device for testing (some Android devices are very cheap now, especially on eBay)
Use the emulator for testing
I see the same issue, but it's to be expected, so I use the phone for debug dev, and the tablet for production testing. When I'm close to a release, I test the production version on both devices and the emulator.
With your testers, I'd advise that you always give them release versions, but you could include extensive logging to help with problems. Debug versions are then only used by you, and release versions by them. If you provide testers with a release version, they use, and accumulate data, when they come to upgrade to the next version, the data can be retained (or updated, if you change the schema) to migrate their data.
I don't see a need for your testers to be using debug & release versions.
Thanks #Evan your solution works perfect:
android {
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
}
To append " (DEBUG)" to your app title when running in debug mode, place this code in your Activity's onCreate:
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
//The .debug specified in gradle
if (pInfo.packageName.equals("YOUR_PACKAGE_NAME_HERE.debug")) {
setTitle(getTitle() + " (DEBUG)");
}
Why uninstall the app? Normally, installing the new version of the same app (identified by the package ID) retains all the app data.
EDIT: to retain app data by hand, copy it from /data/data/my.package.name/... to a safe place, then restore when necessary.
Configure the application id suffix
With the following configuration on your app build.gradle, the release variant will use com.example.myapp applicationId, and the debug variant com.example.myapp.debug
android {
defaultConfig {
applicationId "com.example.myapp"
...
}
...
}
buildTypes {
debug {
applicationIdSuffix ".debug"
...
}
release {
...
}
...
}
Configure multiple Firebase Accounts
If you use Firebase, you will need two Firebase accounts, one for production, and the other for development.
You have to configure Google Services JSONs for each account on its own variant source set:
The production google-services.json on the release source set: app/src/release/google-services.json
The development google-services.json on the release source set: app/src/debug/google-services.json
Providers authorities
If you have defined a provider in your AndroidManifest.xml, now you could have a conflict if both release and debug variants use the same provider authorities and you have both apps installed on the same device. To avoid this issue, a good practice is to use the applicationId as the authority suffix.
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
Custom icon for each variant
If you are going to install multiple variants on the same device, a good idea is to use different app icons, so you can identify them on the launcher.
You just need to design a debug app icon and locate it on src/debug/res/mipmap-xxhdpi-*
Configure FCM
Now that you use different Firebase Accounts, if you have an FCM (push) server, you will need to configure it with the correct credentials.
When a device with the debug app is registered, the FCM server needs to associate the registration token with the debug build type. So, when a push is sent, the token of the Firebase debug credentials is used.
So, you will need to send the build type to the FCM server, every time the app registers the FCM token.
The following article gives more info about this topic: Install your debug & release variants on the same device
For me, I also needed to add:
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
Otherwise, both would receive the same C2D_MESSAGE permission which resulted in:
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=<your applicationId>.permission.C2D_MESSAGE pkg=<your applicationId>]

Categories

Resources