Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable LogCat on Release Build in Android Studio

Tags:

android

logcat

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?

like image 618
Christopher Francisco Avatar asked Sep 01 '14 17:09

Christopher Francisco


People also ask

Can not find Logcat in Android Studio?

Go to Project Structure -> Facets -> “+” -> Android -> Select Project Logcat should now be visible.

Why is my Logcat not showing anything in Android?

Solution 1: Restarting your Android StudioIn your IDE Go to File > Invalidate Caches and Restart > Invalidate and Restart. This Solution will clear all the caches of Android studio IDE and restart it automatically, By the method, there are 80% change that Logcat will start work as before.


2 Answers

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)

like image 145
reVerse Avatar answered Sep 19 '22 06:09

reVerse


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/)

like image 34
Morten Holmgaard Avatar answered Sep 18 '22 06:09

Morten Holmgaard