断点未在 Android Studio 中被击中 [英] Breakpoints not getting hit in Android Studio

查看:23
本文介绍了断点未在 Android Studio 中被击中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows 7,最近从 Eclipse 切换到 Android Studio.我现在在调试时遇到问题.

I'm using Windows 7 and have recently switched from Eclipse to Android Studio. I am now having trouble debugging.

运行 Android Studio 0.8.6,我设置了一个完全默认的安装,我创建了一个默认的空项目,针对 ICS SDK,使用新项目向导.然后我在 onCreate 中放置一个断点,点击调试按钮并运行.

Running Android Studio 0.8.6, I set up a completely default install, I create a default empty project, targeting the ICS SDK, using the new project wizard. I then put a breakpoint in onCreate, click on the debug button and run.

附加调试器,因为我可以在调试器窗口中看到消息已连接到目标 VM".

The debugger attached as I can see the message "Connected to the target VM" in the debugger window.

我知道代码正在执行,因为我正在更新 UI 中的一些文本以显示这一点.

I know the code is being executed because I am updating some text in the UI to show this.

我试过在很多地方设置断点,但都没有命中.

I have tried putting breakpoints in many places but none are hit.

我在这里拔头发,因为我看不出我做错了什么.我是 gradle 的新手,所以我认为 gradle 中可能有一些我应该更改的设置,但是使用向导构建的绝对标准项目肯定会让我遇到断点吗?

I'm pulling my hair out here as I just cannot see what I am doing wrong. I'm new to gradle so I think there may be some settings in gradle that I should be changing, but surely an absolutely standard project built with the wizard should let me hit breakpoints?

我注意到的一件事是在我的 build.gradle 文件中没有提到调试版本,只有一个版本.我想知道这可能是问题吗?

One thing I noticed is that in my build.gradle file there is no mention of a debug build, only a release. I wondered if that might be the problem?

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

注意.我在自己的设备和模拟器上都试过了

Note. I have tried this on both my own device and the emulator

更新:

我更改了查看断点"选项中的设置以打开Java 异常断点",但仅针对未捕获的异常.然后,在 onCreate 结束时,我故意导致 NullPointerException.当我现在在调试中运行时,我仍然没有命中我的实际代码,也没有看到我的源代码中断,但程序确实暂停了.我知道是我的 NullPointerException 导致了这个,因为当我删除它时,我可以看到代码继续并且没有中断.

I changed the settings in the View Breakpoints options to turn on "Java Exception Breakpoints" but only for uncaught exceptions. Then, at the end of onCreate I deliberately cause a NullPointerException. When I run in debug now, I still don't hit my actual code and don't see the code break on my source, but the program does pause. I know it is my NullPointerException that is causing this because when I remove it, I can see that the code continues and does not break.

当我的代码打破调试窗口时,显示我在主"线程中,在一个名为performLaunchActivity"的函数中.我看不到比这更多的信息.大概因此我正在调试调用 performLaunchActivity 的任何级别的代码,但我的源被视为我无法单步执行?

At the point that my code breaks the debug window shows that I am in the "main" thread, in a function called "performLaunchActivity". I cannot see any more information than this. Presumably therefore I am debugging through whatever level of code is calling performLaunchActivity but that my source is being treated as if I can't step through it?

推荐答案

确保你的 JDK 是最新的,并且你的系统只包含一个 JDK.

Make sure your JDK is latest and your system contains only one JDK.

这篇关于断点未在 Android Studio 中被击中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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