Android Studio:忽略静态方法中的断点

时间:2015-05-27 08:36:39

标签: android debugging android-studio

我对Android Studio debugger有疑问:breakpoint 中设置的static method内的non-static methods完全被忽略。另一方面,static method中设置的那些工作完美。

事实上,即使我在呼叫helper classees之前中断,然后手动"进入" 它也不起作用。当我进入时,它会将我的静态方法中的所有代码传递给非静态方法中的第一段代码。

我该如何解决这个问题?它使得查找错误非常困难,因为我的项目中有static methods private void LoadAvailableExperiments(){ //non static methods, breakpoints work fine here try { List<ExperimentStoreEntry> storedExperiments = PackageHelpers.GetStoredExperiments(true); //call to static method } catch (IOException e) { e.printStackTrace(); } //rest of the method }

其他信息

Android工作室版:1.2.1.1
测试Galaxy s5 - Android Lollipop
已经尝试使缓存/重启/清理和重建项目无效 没有重载方法
没有触及预备规则
未启用缩小
代码 实际执行(使用logcat消息测试)

示例代码:

public static List<ExperimentStoreEntry> GetStoredExperiments(boolean cleanInvalidEntries){ //static method. Breakpoints don't work here
        List<ExperimentStoreEntry> entries = new LinkedList<>(); //breakpoint here is never hit
        File dir = new File(IOHelpers.getExperimentsStoragePath()); //nor here
        if(dir.exists()) { //nor here... etc...
            for (File subdir : dir.listFiles()) {
                //rest of the code I won't bore you with...
        }
        return entries;
    }

然后,在PackageHelpers类中:

cout << "Think of a number from 1 to 100, then press y and enter to continue.\n";
char c;
cin >> c;
int min = 1;
int max = 100;

int half(int, int);

vector<int> number;
for (int i = min; i <= max; i++){
    number.push_back(i);
    }

cout << "Is your number from " << number[min - 1] << " to " << number[(max / 2) - 1] << "? y/n. \n";

// the aim of this loop is to 
// 1. bring up the min number to the halfway point between min and max everytime user answer no.
// 2. bring  down the max number to the halfway point everytime user answer yes.
while((cin >> c)&&(min!=max)){

    if (c == 'n'){
        min = half( min, max);
        }

    else if (c == 'y'){
        max = (max + min) / 2;
    }

    else
    {
        cout << "I dont understand your input!\n ";
    }


    cout << "min: " << min << "\t max: " << max << '\n'; // track the limits of the number

    if (min == max){
        cout << "Your number is " << min << "!\nPress ctrl-z!\n";
    }

    else if ((min+max)%2)
    cout << " Is your number from " << number[min - 1] << " to " << number[half(min, max) - 2] << "? y/n.\n";
    // because we added extra 1 in the half function for odd sums, we have to compensate here by deducting 2.

    else
    cout << " Is your number from " << number[min - 1] << " to " << number[half(min,max)-1] << "? y/n.\n";

}

keep_window_open(); // part of std_lib header, prompts enter character to exit
}

int half (int x, int y){
    if ((x + y) % 2){
        return ((x + y) / 2) + 1; // because division always round down, so for odd number division we add 1 to be inclusive.
    }
    else
        return (x + y) / 2;
编辑:请问,如果你问题是这样,至少在评论中说明为什么我可以改进它。我不知道还有什么要坦率地说:/

1 个答案:

答案 0 :(得分:1)

正如FunkTheMonk所指出的,这是GalaxyS5上第一个Lollipop发布的问题。将设备更新到最新固件解决了这个问题。

请点击此处了解详情:Galaxy S5 Lollipop - not all breakpoints stop execution under Android Studio debugger