1

Recently I'm trying to use LeakCanary to fix OOM(out of memory) issues for my Android app. And I added

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'

to my build.gradle, following the instructions on LeakCanary website. After gradle build, I got

"/android-sdk/android-sdk_r22.6.2-linux/build-tools/21.1.1/aapt'' finished with non-zero exit value 1 

This is part of my 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'
}
Logic
  • 2,230
  • 2
  • 24
  • 41
CherryWang
  • 21
  • 3

2 Answers2

1

When I updated the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1, it worked. Hope this can help anyone having this problem.

CherryWang
  • 21
  • 3
0

I changed

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'

to

dependencies {
    classpath 'com.android.tools.build:gradle:1.1.3'

As well as the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1 as suggested by CherryWang https://stackoverflow.com/a/30496364/1247248

I got this from a comment in Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)

Community
  • 1
  • 1
Marc
  • 1,159
  • 17
  • 31