Search code examples
androidkotlinandroid-gradle-plugingradle-kotlin-dsl

Kotlin DSL: Why am I able to get logs in release build from Play Store?


We did not enable logging in release mode yet when we connect a USB cable and run Android Studio, we're able to get logs from release build downloaded from the store.

buildTypes {
        debug {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )

            configure<CrashlyticsExtension> {
                // No need during development, enabling it also prevents Gradle to work offline
                mappingFileUploadEnabled = false
            }

            signingConfig = signingConfigs.getByName("debug")
        }
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )

            signingConfig = signingConfigs.getByName("release")
        }
    }

Do we need to explicitly disable logging in build variant when using Kotlin DSL?

For confidentiality this is a compact view of log, but these logs are pointing to app's package name. Running on Samsung A32 Android 13.

02:37:01.463  I  ViewPostIme pointer 0
02:37:01.563  I  ViewPostIme pointer 1
02:37:01.581  D  initGoToTop
02:37:01.594  D  [NativeCFMS] BpCustomFrequencyManager::BpCustomFrequencyManager()
02:37:01.631  I  Relayout returned: old=(0,80,1080,2274) new=(28,669,1052,1684) req=(1024,1015)0 dur=10 res=0x3 s={true 0xb400006f071bd800} ch=true seqId=0
02:37:01.632  I  mThreadedRenderer.initialize() mSurface={isValid=true 0xb400006f071bd800} hwInitialized=true
02:37:01.632  D  eglCreateWindowSurface
02:37:01.637  D   onsize change changed 
02:37:01.638  I  reportNextDraw android.view.ViewRootImpl.performTraversals:4438 android.view.ViewRootImpl.doTraversal:3116 android.view.ViewRootImpl$TraversalRunnable.run:10885 android.view.Choreographer$CallbackRecord.run:1301 android.view.Choreographer$CallbackRecord.run:1309 
02:37:01.638  I  Setup new sync id=0
02:37:01.639  I  Setting syncFrameCallback
02:37:01.639  I  registerCallbacksForSync syncBuffer=false
02:37:01.643  I  Received frameDrawingCallback syncResult=0 frameNum=1.
02:37:01.643  I  Setting up sync and frameCommitCallback

Solution

  • Might be mistaken, but you might need to add a proGuard rule to your proguard-rules.pro, something like:

    -assumenosideeffects class android.util.Log {
        public static int d(...);
        public static int e(...);
        public static int i(...);
        public static int v(...);
        public static int w(...);
    }
    

    (source: Removing Log call using proguard)