最近我尝试使用LeakCanary为我的Android应用修复OOM(内存不足)问题。我添加了
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
到我的build.gradle,按照LeakCanary网站上的说明操作。在gradle构建之后,我得到了
"/android-sdk/android-sdk_r22.6.2-linux/build-tools/21.1.1/aapt'' finished with non-zero exit value 1
这是我的build.gradle的一部分:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'android'
apply plugin: 'maven'
android {
compileSdkVersion 19
buildToolsVersion '22.0.1'
defaultConfig {
multiDexEnabled true
}
lintOptions {
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
res.srcDirs = ['res']
}
instrumentTest.setRoot('tests')
}
dexOptions {
jumboMode = true
preDexLibraries = false
javaMaxHeapSize = '2g'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url "http://XXXXX/nexus/content/repositories/releases"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name: 'ShortcutBadger-1.0.1', ext: 'aar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
答案 0 :(得分:1)
当我将CompileSDKVersion更新为22并将buildToolsVersion更新为22.0.1时,它可以正常工作。 希望这可以帮助任何有这个问题的人。
答案 1 :(得分:0)
我改变了
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
到
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
与CherryWang https://stackoverflow.com/a/30496364/1247248建议的CompileSDKVersion到22和buildToolsVersion到22.0.1一样
我是通过Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)
中的评论得到的