68

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?

Christopher Francisco
  • 13,553
  • 23
  • 77
  • 181
  • 1
    Change your log level. I may be wrong but as I understand it `Log.d` calls are removed when a release version is exported - I'm not sure what other levels (if any) are also removed. – Squonk Sep 01 '14 at 18:02
  • @Squonk I have also recently observed that Log.v logs are also not exposed in release build. Do any one know what can be the reason for it? – Manmohan Soni Oct 16 '19 at 12:40

3 Answers3

75

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)

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
reVerse
  • 33,862
  • 21
  • 85
  • 82
  • 2
    I don't think this answer is correct. At least, the docs it cites don't say that turning on `android:debuggable` will turn on logging. In fact, https://developer.android.com/studio/publish/preparing.html#publishing-configure is fairly clear that turning off logging and turning off debugging are two separate things. The OP asked how to turn on logging. – LarsH Oct 27 '17 at 18:26
  • P.S. Please correct me if I'm wrong, citing a source that says that `android:debuggable="true"` enables logging. – LarsH Oct 27 '17 at 18:34
  • 4
    You're somewhat right, but `debuggable` means that the Android Monitor in Android Studio can be attached to the currently running APK. This enables the Logcat to show the log statements like in debug builds. Other than that: This answer is now a little bit over three years old - so most probably you should switch to the corresponding `build.gradle` property called `debuggable` which can be set depending on the buildType. – reVerse Oct 28 '17 at 09:44
33

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

Morten Holmgaard
  • 6,452
  • 6
  • 55
  • 79
  • 3
    http://joxi.ru/eAOl5EWu8Ll5ro App from market with debuggable not mentioned in manifest (thus, it's false). Nothing - in AS LogCat or in DeviceMonitor – Den Drobiazko Jul 08 '15 at 09:22
  • 5
    you will not see Log.v and Log.d this way – NikkyD Feb 23 '17 at 12:18
  • @DenRimus, in Play Market, I think, an application should be in release mode. So, there can be turned off all logs. – CoolMind May 19 '17 at 09:17
  • You won't be able to filter this way because you can't see which log corresponds to your package. – JensV Sep 07 '17 at 12:47
  • @JensV you could still filter by your package name, right? – IHC_Applroid Sep 20 '17 at 22:45
  • @IHC_Applroid No, if the App isn't set as debuggable, you will only see the pid, tag, level and message. – JensV Sep 21 '17 at 04:41
  • Note too that in ADM LogCat window, you also can't filter on tags *by typing in the live filter field.* That field seems to filter only on message text. Instead, you can add saved filters to filter by tag. – LarsH Oct 27 '17 at 19:51
  • Android Device Monitor was removed in AS 3.2 - https://developer.android.com/studio/profile/monitor However, it is still present in SDK, and you can use it to see the logs (it is located in `$ANDROID_SKD/tools/`) – Vadim Kotov May 28 '19 at 14:38
  • You can also use 3rd party app like [Facebook Flipper](https://fbflipper.com/) to get the logs even in release version. – Vadim Kotov Jun 06 '19 at 11:08
  • There's a typo: should be `$ANDROID_SDK/tools/` instead of `$ANDROID_SKD/tools/` - unfortunately I cannot save my edit – Remigius Stalder Apr 07 '21 at 14:52
29

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.

CoolMind
  • 16,738
  • 10
  • 131
  • 165
  • 4
    This works for me. Having logs in release build is necessary at lease after enabling proguard for the first time. But don't forget to make `debuggable false` for production builds :) – MohK Nov 19 '19 at 09:51
  • @MohK, agree with you. Strange, but in another project I have `debuggable false` in `release` build, but see logs and debugging does not work even in `true` state. :) – CoolMind Nov 19 '19 at 11:39
  • It seems it only works with System.out.println() in the new versions of AS. – IldiX Feb 26 '20 at 16:06
  • @IldiX, did you also try Kotlin `println()` or `Timber.`? – CoolMind Feb 26 '20 at 16:11
  • @CoolMind the project is in java. – IldiX Feb 27 '20 at 14:37
  • @IldiX, I have `debuggable false` in `release` build (`minifyEnabled true`, `shrinkResources true`), but `Log.d()` works. AS 3.6.1. – CoolMind Mar 04 '20 at 13:38