【问题标题】:How do you use usb debugging with eclipse and real android device你如何在eclipse和真正的android设备上使用usb调试
【发布时间】:2013-04-02 23:02:22
【问题描述】:

我正在尝试使用我的 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>

【问题讨论】:

  • 你的代码在哪里有你的断点?您可以在使用时向我们展示它和清单吗?
  • 按要求进行了编辑,我在代码中添加了一个 console.out.println() 以确保正在调用此行,并且我确实在 logcat 中看到了我的 println
  • 非常清楚:您在 logcat 中看到“我的断点之前的行”? (它没有反映在您当前的 logcat 中)
  • 我刚刚添加了那个....我发现了问题。在控件中以某种方式跳过所有断点

标签: android debugging


【解决方案1】:

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

【讨论】:

  • 如果我不想在调试中运行,我会有显示调试器已解决的 logcat 记录吗?并且 Debugger 已经连接了?
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

    <application
        android:debuggable="true"
        ... >
        ...
    </application>
    

    【讨论】:

      猜你喜欢
      • 2012-02-26
      • 2011-02-12
      • 2012-10-15
      • 2014-06-13
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多