Android Studio – Cannot find local variable while debugging
by Riley MacDonald, August 25, 2017

Problem
When attempting to debug an issue using the Android Studio Debugger I was unable to evaluate any expressions using the Debugger. Attempting to evaluate any variable resulted in the error message “Cannot find local variable ‘variable'”.

Potential Solution
This solution temporarily resolved the issue for me. I’m not sure if this will work for others. My build.gradle contained the following configuration for debug build flavors:

buildTypes {
        debug {
            testCoverageEnabled = true
        }
    }
}

Setting testCoverageEnabled to false resolved the issue for me. After setting it I was able to evaluate all expressions using the debugger:

buildTypes {
        debug {
            testCoverageEnabled = false
        }
    }
}

I recommend reverting this change after performing the required debugging.

Open the comment form

Leave a comment:

Comments will be reviewed before they are posted.

User Comments:

Be the first to leave a comment on this post!