debugging – Android studio gradle breakpoint No executable code found at line-ThrowExceptions

Exception or error:

I am developing an android application using Android Studio 2.1.3 and gradle.

The problem is that the breakpoint in a simple method is never hit, although it must be hit because the condition is met during application debugging.
First, I thought that the problem is related to the issue described in the answer for this question:
BuildConfig.DEBUG always false when building library projects with gradle

To test this, I removed library project and integrated all my source code into the main app module. It solved nothing.
To be noted that the following is the build.gradle, where minify is set to false for both debug/release:

apply plugin: 'com.android.application'  

android {  
    compileSdkVersion 23  
    buildToolsVersion "23.0.2"  
    defaultConfig {  
        applicationId "com.mycompany.mymobileapp"  
        minSdkVersion 21  
        targetSdkVersion 21  
        versionCode 1  
        versionName "1.0"  
    }  
    buildTypes {  
        release {  
            minifyEnabled false  
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
            debuggable true  
            jniDebuggable true  
            renderscriptDebuggable true  
            zipAlignEnabled false  
        }  
        debug {  
            debuggable true  
            minifyEnabled false  
            zipAlignEnabled false  
            jniDebuggable true  
            renderscriptDebuggable true  
        }  
    }  
    productFlavors {  
    }  
}  
  
dependencies {  
    compile fileTree(include: ['*.jar'], dir: 'libs')  
    testCompile 'junit:junit:4.12'  
    testCompile 'org.mockito:mockito-core:2.0.5-beta'  
    testCompile 'com.android.support:support-v4:23.1.1'  
    testCompile 'org.powermock:powermock-api-mockito:1.6.2'  
    testCompile 'org.powermock:powermock-module-junit4-rule-agent:1.6.2'  
    testCompile 'org.powermock:powermock-module-junit4-rule:1.6.2'  
    testCompile 'org.powermock:powermock-module-junit4:1.6.2'  
    compile 'com.android.support:appcompat-v7:23.1.1'  
}

Here is the screenshot with what Android Studio shows to me:

No executable code found problem

This is also not the only case. It happens that the compiler, while Stepping over, jumps to completely another part of the code than the one being debugged.

Is there any reasonable explanation here?
Suspend: “thread” and “all” tried, same result.

UPDATE 1:
Re-created the project using Eclipse, and everything works fine.
It is still amazing why using Android studio this does not work!

How to solve:
buildTypes {

release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt')

}
debug {
    debuggable true
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt')

    }
}

Set minifyEnabled false in debug block in build.gradle file.

###

After re-creating the application using Eclipse and observing the correct behavior, I returned to Android Studio in order to check if there is any option that I missed.

After trying all the options from File -> Settings that I could, I made the conclusion that Instant Run is the evil that caused me to waste so much precious time.

I don’t understand how it is related with my problem, but after clearing all check-boxes:

enter image description here

I ended up with a code that executes the way I as a developer expect:

enter image description here

###

I was facing a similar issue.

I’ve tried:

  • Cleaning the Project
  • Resetting Android Studio
  • Rebuilding the project
  • Disabling the Instant Run

and it didn’t work.

All I did in the end to make it work was Ctrl+Shift++. That is the shortcut for expanding all code blocks. I just ran the project after that and it worked.

###

try to clean and rebuild the project.
try to make some log in this method to check if the it being executed.

LOG.(TAG,"method being executed")

###

Restart Android Studio

If you know that nothing was changed that can cause this since it was working before. Then try by closing and restarting Android Studio. That worked for me on Android Studio 3.5.

Clean build did not work for me

###

Uninstalling and installing the App on the test device solved my issue.

I tried:

  • Cleaning/rebuilding the Project
  • Resetting Android Studio, Clean Cache
  • Setting the debugger to stop on all threads
  • There is no minifyEnabled in my debug variant.

Disabling the Instant Run wasn’t an option as of Android Studio 3.6
so I didn’t try it. see this StackOverflow question

###

It`s problem with studio cache.
File -> Invalidate Caches / Restatrt… May help you.

Leave a Reply

Your email address will not be published. Required fields are marked *