我想使用我的三星注入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>
在你的代碼中你有斷點嗎?你可以向我們展示那個和清單嗎? – DigCamara
編輯按要求,我添加了一個console.out.println()我的代碼,以確保此行被調用,我確實在logcat中看到我的println –
要非常清楚:你看到「斷線之前的行」在你的logcat? (它不是反映在你當前的logcat中) – DigCamara