2013-04-02 21 views
0

我想使用我的三星注入4g手機調試Android應用程序。在手機上啓用了USB調試。我在清單中添加了debuggable = true; Logcat說調試器已經解決了(1325)。但是,當我運行代碼時,它不會停止在我的斷點處,並且在變量窗口中看不到任何變量。任何想法這裏有什麼問題?這是logcat輸出:你如何使用USB調試日食和真正的Android設備

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> 
+0

在你的代碼中你有斷點嗎?你可以向我們展示那個和清單嗎? – DigCamara

+0

編輯按要求,我添加了一個console.out.println()我的代碼,以確保此行被調用,我確實在logcat中看到我的println –

+0

要非常清楚:你看到「斷線之前的行」在你的logcat? (它不是反映在你當前的logcat中) – DigCamara

回答

1

運行應用程序確保「跳過所有斷點」調試控件未啓用。

1

您需要在調試模式下

Debug Mode

+0

被選中,如果我不想在調試運行我會有logcat記錄顯示調試器已解決?和調試器已連接? –

0

在AndroidManifest.xml中聲明您的應用程序爲「debuggable」。

<application 
    android:debuggable="true" 
    ... > 
    ... 
</application> 
相關問題