Android Studio的调试器不会在库模块中的断点处停止 [英] Android Studio's debugger not stopping at breakpoints within library modules

查看:1873
本文介绍了Android Studio的调试器不会在库模块中的断点处停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在开发基于第三方代码的Android应用。我开始设置断点来理解代码,很快就遇到了一个问题。突然间,我无法让Android Studio停止在断点。

At the moment I'm developing an Android app that is based on third party code. I started to set breakpoints for understanding the code and soon ran into a problem. Suddenly I couldn't get Android Studio to stop at breakpoints anymore.

我试图在 onCreate 中设置断点方法,在按钮' OnClickListener s - 没有任何工作。现在我发现它唯一的工作地方在应用程序模块内。由于该项目在应用程序模块中只有一个活动类,所有其他内容都在库模块中提供,实际上我根本无法调试。

I tried to set the breakpoints within onCreate methods, within buttons' OnClickListeners - nothing worked. Now I found out that the only place it works is inside the app module. As the project just has one single activity class in the app module and everything else is provided within library modules in fact I can't debug at all.

我假设有东西在AndroidManifest.xml或更有可能在build.gradle文件中出错。当我从Eclipse切换到Android Studio时,所有这些毕业的东西对我来说都是新的。

I assume there's something wrong in the AndroidManifest.xml or more likely in the build.gradle file. As I just switched from Eclipse to Android Studio, all of this gradle stuff is pretty new to me.

如果我在应用程序运行时将鼠标悬停在库断点上,它会告诉我行中没有找到可执行代码。我认为这是我的问题的原因,但我不知道如何解决它。

If I hover over a library breakpoint while the app is running, it tells me that "no executable code [is] found at line ...". I assume this is the cause of my problem, but I have no idea about how to fix it.

在build.gradle的条目中是否有任何通常的嫌疑犯这可能会导致我的问题?

Are there any "usual suspects" among the entries in build.gradle that could cause my problem?

我已经清理了我的项目,无效成功缓存了缓存。我甚至尝试在库模块内添加< activity> 条目的建议。

I already did clean my project and invalidated the cache without success. I even tried the suggestion to add <activity> entries inside the library module for the fragments inside.

编辑:我使用的是最新版本的Android Studio(从2月18日起的版本1.1.0),它应该有一段时间以前存在的类似错误。

Edit: I'm using the most current version of Android Studio (version 1.1.0 from February 18) which should have the similar bug fixed that existed some time ago.

应用模块中build.gradle的内容:

The contents of build.gradle in the app module:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion Integer.parseInt(project.MIN_SDK)
        targetSdkVersion  Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

    signingConfigs {
        release {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('xxx')
            storePassword 'xxx'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
            debuggable false
            jniDebuggable false
            zipAlignEnabled true
        }
        debug {
            minifyEnabled false
            debuggable true
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':firebase_plugin')
}

和图书馆模块的build.gradle:

And the build.gradle of library module:

apply plugin: 'com.android.library'
android {

    compileSdkVersion 19
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
    defaultConfig {
        minSdkVersion Integer.parseInt(project.MIN_SDK)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

    buildTypes {
        release {
            minifyEnabled true
            zipAlignEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            minifyEnabled false
            debuggable true
        }
    }

    productFlavors {
    }

}

dependencies {
    // Facebook SDK
    compile project(':facebook')

    // Used for StringUtils
    compile files('libs/commons-lang3-3.3.2.jar')
    // Bug tracking
    compile files('libs/bugsense-3.6.1.jar')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //Google Play Services - For Google Maps
    compile('com.google.android.gms:play-services:5.0.89') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    // Support Library.
    compile 'com.android.support:support-v13:18.0.+'

    compile('com.android.support:appcompat-v7:19.1.0') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    // Volley - Networking library from google.
    compile('com.mcxiaoke.volley:library:1.0.0') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    // Has is own support library in it so need to exclude it so no TOP_LEVEL_EXCEPTION will occur.
    compile('de.greenrobot:greendao:1.3.0') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    // Firebase
    compile('com.firebase:firebase-simple-login:1.4.2') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    // Super Toast
    compile('com.github.johnpersano:supertoasts:1.3.4@aar') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    // Croping images
    compile('com.soundcloud.android:android-crop:0.9.10@aar') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile('com.github.chrisbanes.actionbarpulltorefresh:library:0.9.9') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
}


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':firebase_plugin')
}

推荐答案

如本问题的注释所述,在调试版本中设置 minifyEnabled false 是最佳做法。通过在应用程序模块中设置此变量,您将禁用整个proguard构建过程。在优化发布版本时非常有用,但如果您正在测试和开发,则会出现一些问题。

As stated in the comments of this issue, setting minifyEnabled false in the debug build is the best practice. By setting this variable in the app module you are disabling the entire proguard build process. It is useful when optimizing the release build, but gives some problems if you are testing and developing.

这篇关于Android Studio的调试器不会在库模块中的断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆