簡體   English   中英

你如何使用eclipse和真正的Android設備進行usb調試

[英]How do you use usb debugging with eclipse and real android device

我正在嘗試使用我的三星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>

您需要以調試模式運行應用程序

調試模式

確保在調試控件中未啟用“跳過所有斷點”。

在AndroidManifest.xml中將您的應用程序聲明為“debuggable”。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM