问题描述
我正在使用 Android Studio 2.1.3 和 gradle 开发一个 android 应用程序.
问题是简单方法中的断点永远不会被命中,尽管它必须被命中,因为在应用程序调试期间满足条件.
首先,我认为这个问题与这个问题的答案中描述的问题有关:
这也不是唯一的情况.碰巧编译器在 Stepping 时完全跳到了代码的另一部分,而不是被调试的部分.
这里有什么合理的解释吗?Suspend: "thread" 和 "all" 都试过了,结果一样.
更新 1:使用 Eclipse 重新创建项目,一切正常.还是很奇怪为什么用 Android studio 不行!
使用 Eclipse 重新创建应用程序并观察正确行为后,我返回 Android Studio 以检查是否有任何我错过的选项.
在尝试了文件 -> 设置中的所有选项后,我得出结论,即时运行是导致我浪费如此多宝贵时间的邪恶.
我不明白它与我的问题有什么关系,但是在清除所有复选框后:
我最终得到了一个按照开发人员期望的方式执行的代码:
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:
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!
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 断点在行中找不到可执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!