Android Studio Gradle断点在行上找不到可执行代码 [英] Android studio gradle breakpoint No executable code found at line

查看:121
本文介绍了Android Studio Gradle断点在行上找不到可执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 2.1.3和gradle开发一个android应用程序.

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

问题在于,尽管必须击中简单方法中的断点,但因为在应用程序调试期间满足了条件,所以必须击中断点.
首先,我认为该问题与该问题的答案中所述的问题有关: BuildConfig.DEBUG在使用gradle构建库项目时始终为false

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

为了测试这一点,我删除了库项目并将所有源代码集成到主应用程序模块中.它什么也没解决. 要注意的是,以下是build.gradle,其中将debug/release的minify都设置为false:

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'  
}

以下是Android Studio向我显示的屏幕截图:

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

这也不是唯一的情况.碰巧编译器在跳过时会完全跳到代码的另一部分,而不是被调试的那一部分.

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.

更新1: 使用Eclipse重新创建了项目,并且一切正常. 为何使用Android Studio不能正常工作,仍然令人惊奇!

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

推荐答案

使用Eclipse重新创建应用程序并观察正确的行为后,我返回Android Studio,以检查是否有任何我错过的选项.

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:

最后我得到了一个代码,该代码执行了开发人员期望的方式:

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

这篇关于Android Studio Gradle断点在行上找不到可执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆