0

我正在尝试使用我的 Samsung Infuse 4g 手机调试 android 应用程序。手机开启usb调试。我在清单中添加了 debuggable = true; Logcat 说调试器已经解决(1325)。但是当我运行代码时,它不会在我的断点处停止,并且我在变量窗口中看不到任何变量。任何想法这里出了什么问题?这是 logcat 输出:

04-03 00:55:47.210: I/System.out(8726): Sending WAIT chunk
04-03 00:55:47.218: I/dalvikvm(8726): Debugger is active
04-03 00:55:47.415: I/System.out(8726): Debugger has connected
04-03 00:55:47.415: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:47.613: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:47.819: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:48.023: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:48.234: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:48.433: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:48.636: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:48.839: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:49.042: I/System.out(8726): waiting for debugger to settle...
04-03 00:55:49.249: I/System.out(8726): debugger has settled (1325)

我唯一一次看到调试器正在做某事是当我故意使程序崩溃时。然后我看到了 Double.ParseDouble(String) 的异常,但我错过了它的源代码......我什至尝试了模拟器,我遇到了同样的问题,直到我崩溃程序之前没有调试。

package com.example.calculator;



public  class Math {
double mathValue;
double totalValue;
int lastOperator;

public double getTotalValue(){
    if (this.totalValue == 0)
        return this.mathValue;
    else
    return this.totalValue;
}

public void add(){

}

public void setOperater(String nextOperater){
    if (nextOperater == "+")
        this.lastOperator = 1;

    if (nextOperater == "-")
        this.lastOperator = 2;

    if (nextOperater == "*")
        this.lastOperator = 3;

    if (nextOperater == "/")
        this.lastOperator = 4;

    if (nextOperater == "")
        this.mathValue = 0;



}

public void doMath(double inValue){
    this.mathValue = inValue;
    switch (lastOperator){
    case 1 : Add();
            break;
    case 2 : Subtract();
            break;
    case 3 : Multiply();
            break;
    case 4: Divide();
            break;

    }

}

public void Add(){
    System.out.println("The line before my breakpoint");
    totalValue += mathValue; <---- break point
    System.out.println("The line after my breakpoint");
}

public void Subtract(){

    totalValue -= mathValue;
}

public void Multiply(){

    totalValue *= mathValue;
}

public void Divide(){
    if (mathValue == 0)
        totalValue = 0;
    else
        totalValue /= mathValue;

}

}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.calculator"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" 
        android:debuggable="true">
        <activity
            android:name="com.example.calculator.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
4

3 回答 3

1

您需要在调试模式下运行应用程序

调试模式

于 2013-04-02T23:44:20.453 回答
1

确保在调试控件中未启用“跳过所有断点”。

于 2013-04-03T00:48:20.010 回答
0

在 AndroidManifest.xml 中将您的应用程序声明为“可调试”。

<application
    android:debuggable="true"
    ... >
    ...
</application>
于 2013-11-08T14:39:51.520 回答