【发布时间】:2015-05-04 08:47:27
【问题描述】:
目前我正在开发一个基于第三方代码的 Android 应用。我开始设置断点来理解代码,很快就遇到了问题。突然间,我再也无法让 Android Studio 在断点处停止了。
我尝试在按钮的OnClickListeners 内的 onCreate 方法中设置断点 - 没有任何效果。现在我发现它唯一起作用的地方是在应用程序模块内。由于该项目在应用程序模块中只有一个活动类,而其他所有内容都在库模块中提供,实际上我根本无法调试。
我认为 AndroidManifest.xml 或 build.gradle 文件中可能有问题。当我刚从 Eclipse 切换到 Android Studio 时,所有这些 gradle 的东西对我来说都很新鲜。
如果我在应用程序运行时将鼠标悬停在库断点上,它会告诉我“在...行中找不到 [is] 可执行代码”。我认为这是我的问题的原因,但我不知道如何解决它。
build.gradle 中的条目中是否有任何“通常的嫌疑人”可能导致我的问题?
我已经清理了我的项目并使缓存无效但没有成功。我什至尝试了在库模块中为内部片段添加<activity> 条目的建议。
编辑:我使用的是最新版本的 Android Studio(2 月 18 日的 1.1.0 版),它应该修复了前一段时间存在的类似错误。
app模块中build.gradle的内容:
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:
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')
}
【问题讨论】:
-
不是,我主要是用模拟器(genymotion)
-
好的,我问这个是因为主要在带有棒棒糖的 S5 中存在一个会产生这种不良行为的错误。请发布您的一些代码/ gradle 文件,以便我们找出问题所在。 android studio 版本也很有用
-
我刚刚在我的索尼设备上进行了测试,以确保它与模拟器无关。它也没有在那里工作。我将在一分钟内用两个主要 build.gradle 文件的内容更新问题。
-
从图中可以看出,AS 正在为您的库的所有配置运行构建调试。我建议您只在 gradle 调试库模块中进行以下配置: minifyEnabled false debuggable true
-
@Feantury 你能用
minifyEnabled false添加提示以禁用ProGuard 作为答案,以便我接受吗?这是指向正确方向的提示,如果我做对了所有事情,大概会有所帮助;-)
标签: android debugging android-studio breakpoints