Leakcanary: Library leakcanary-android-1.3 is not in list of external libraries

Created on 9 May 2015  Â·  40Comments  Â·  Source: square/leakcanary

I have a project with lots of dependencies.
When I add

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

to main build.gradle, leakcanary-android is not in list of external libraries after gradle sync, although leakcanary-analyzer and leakcanary-watcher are there.
See screenshot:
screen shot 2015-05-09 at 18 59 23

On a blank project however everything works fine:
screen shot 2015-05-09 at 18 59 09

Most helpful comment

In my case, I had a custom buildType

buildTypes {
    bypass {
       // Some parameters
    }
}

I just had to use bypassCompile instead of debugCompile

All 40 comments

That's really strange, leakcanary-analyzer is a transitive dependency of leakcanary-android.

Can you paste the dependency tree here? ./gradlew :YOUR_GRADLE_MODULE:dependencies

Also:

  • Is the LeakCanary class available in the classpath? Can you write debug code that uses it?
  • Do you have more build types than just debug and release ?

LeakCanary is not available, but LeakTrace and LeakTraceElement are available.
I don't have any custom build types.
Gradle version 2.2.1
Android plugin version 1.2.3
Android studio version 1.2.1.1

Here is dependency tree:

:app:dependencies

------------------------------------------------------------
Project :app - Injects the build id used by the Fabric SDK.
------------------------------------------------------------

_debugAndroidTestApk - ## Internal use, do not manually configure ##
No dependencies

_debugAndroidTestCompile - ## Internal use, do not manually configure ##
No dependencies

_debugApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.1.1
|    \--- com.android.support:support-v4:22.1.1
|         \--- com.android.support:support-annotations:22.1.1
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
|    +--- com.crashlytics.sdk.android:answers:1.1.2
|    |    \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
|    +--- io.fabric.sdk.android:fabric:1.3.0
|    \--- com.crashlytics.sdk.android:beta:1.1.2
|         \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0
+--- org.immutables:gson:1.1.3
|    \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.0
+--- com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1
+--- de.greenrobot:eventbus:2.4.0
+--- com.github.chrisbanes.photoview:library:1.2.3
|    \--- com.android.support:support-v4:19.+ -> 22.1.1 (*)
+--- com.twitter:twitter-text:1.6.1
|    \--- org.yaml:snakeyaml:1.12
+--- project :innbxtextview
|    \--- com.android.support:appcompat-v7:22.1.1 (*)
+--- project :SwipeCards
+--- project :viewpagerindicator
|    \--- com.android.support:support-v4:22.1.1 (*)
+--- project :PagerStrip
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- project :innbxtextview (*)
+--- project :fab
|    \--- com.android.support:support-annotations:22.1.1
+--- project :slidingup
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- com.nineoldandroids:library:2.4.0
\--- com.squareup.leakcanary:leakcanary-android:1.3
     \--- com.squareup.leakcanary:leakcanary-analyzer:1.3
          +--- com.squareup.haha:haha:1.1
          \--- com.squareup.leakcanary:leakcanary-watcher:1.3

_debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.1.1
|    \--- com.android.support:support-v4:22.1.1
|         \--- com.android.support:support-annotations:22.1.1
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
|    +--- com.crashlytics.sdk.android:answers:1.1.2
|    |    \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
|    +--- io.fabric.sdk.android:fabric:1.3.0
|    \--- com.crashlytics.sdk.android:beta:1.1.2
|         \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0
+--- org.immutables:gson:1.1.3
|    \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.0
+--- com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1
+--- de.greenrobot:eventbus:2.4.0
+--- com.github.chrisbanes.photoview:library:1.2.3
|    \--- com.android.support:support-v4:19.+ -> 22.1.1 (*)
+--- com.twitter:twitter-text:1.6.1
|    \--- org.yaml:snakeyaml:1.12
+--- project :innbxtextview
|    \--- com.android.support:appcompat-v7:22.1.1 (*)
+--- project :SwipeCards
+--- project :viewpagerindicator
|    \--- com.android.support:support-v4:22.1.1 (*)
+--- project :PagerStrip
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- project :innbxtextview (*)
+--- project :fab
|    \--- com.android.support:support-annotations:22.1.1
+--- project :slidingup
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- com.nineoldandroids:library:2.4.0
\--- com.squareup.leakcanary:leakcanary-android:1.3
     \--- com.squareup.leakcanary:leakcanary-analyzer:1.3
          +--- com.squareup.haha:haha:1.1
          \--- com.squareup.leakcanary:leakcanary-watcher:1.3

_debugUnitTestApk - ## Internal use, do not manually configure ##
No dependencies

_debugUnitTestCompile - ## Internal use, do not manually configure ##
No dependencies

_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.1.1
|    \--- com.android.support:support-v4:22.1.1
|         \--- com.android.support:support-annotations:22.1.1
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
|    +--- com.crashlytics.sdk.android:answers:1.1.2
|    |    \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
|    +--- io.fabric.sdk.android:fabric:1.3.0
|    \--- com.crashlytics.sdk.android:beta:1.1.2
|         \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0
+--- org.immutables:gson:1.1.3
|    \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.0
+--- com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1
+--- de.greenrobot:eventbus:2.4.0
+--- com.github.chrisbanes.photoview:library:1.2.3
|    \--- com.android.support:support-v4:19.+ -> 22.1.1 (*)
+--- com.twitter:twitter-text:1.6.1
|    \--- org.yaml:snakeyaml:1.12
+--- project :innbxtextview
|    \--- com.android.support:appcompat-v7:22.1.1 (*)
+--- project :SwipeCards
+--- project :viewpagerindicator
|    \--- com.android.support:support-v4:22.1.1 (*)
+--- project :PagerStrip
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- project :innbxtextview (*)
+--- project :fab
|    \--- com.android.support:support-annotations:22.1.1
+--- project :slidingup
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- com.nineoldandroids:library:2.4.0
\--- com.squareup.leakcanary:leakcanary-android-no-op:1.3
     \--- com.squareup.leakcanary:leakcanary-watcher:1.3

_releaseCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.1.1
|    \--- com.android.support:support-v4:22.1.1
|         \--- com.android.support:support-annotations:22.1.1
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
|    +--- com.crashlytics.sdk.android:answers:1.1.2
|    |    \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
|    +--- io.fabric.sdk.android:fabric:1.3.0
|    \--- com.crashlytics.sdk.android:beta:1.1.2
|         \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0
+--- org.immutables:gson:1.1.3
|    \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.0
+--- com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1
+--- de.greenrobot:eventbus:2.4.0
+--- com.github.chrisbanes.photoview:library:1.2.3
|    \--- com.android.support:support-v4:19.+ -> 22.1.1 (*)
+--- com.twitter:twitter-text:1.6.1
|    \--- org.yaml:snakeyaml:1.12
+--- project :innbxtextview
|    \--- com.android.support:appcompat-v7:22.1.1 (*)
+--- project :SwipeCards
+--- project :viewpagerindicator
|    \--- com.android.support:support-v4:22.1.1 (*)
+--- project :PagerStrip
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- project :innbxtextview (*)
+--- project :fab
|    \--- com.android.support:support-annotations:22.1.1
+--- project :slidingup
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- com.nineoldandroids:library:2.4.0
\--- com.squareup.leakcanary:leakcanary-android-no-op:1.3
     \--- com.squareup.leakcanary:leakcanary-watcher:1.3

_releaseUnitTestApk - ## Internal use, do not manually configure ##
No dependencies

_releaseUnitTestCompile - ## Internal use, do not manually configure ##
No dependencies

androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128

androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.4.201502262128
     +--- org.jacoco:org.jacoco.core:0.7.4.201502262128
     |    \--- org.ow2.asm:asm-debug-all:5.0.1
     +--- org.jacoco:org.jacoco.report:0.7.4.201502262128
     |    +--- org.jacoco:org.jacoco.core:0.7.4.201502262128 (*)
     |    \--- org.ow2.asm:asm-debug-all:5.0.1
     \--- org.jacoco:org.jacoco.agent:0.7.4.201502262128

androidTestApk - Classpath packaged with the compiled 'androidTest' classes.
No dependencies

androidTestCompile - Classpath for compiling the androidTest sources.
No dependencies

androidTestProvided - Classpath for only compiling the androidTest sources.
No dependencies

androidTestWearApp - Link to a wear app to embed for object 'androidTest'.
No dependencies

apk - Classpath packaged with the compiled 'main' classes.
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:22.1.1
|    \--- com.android.support:support-v4:22.1.1
|         \--- com.android.support:support-annotations:22.1.1
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
|    +--- com.crashlytics.sdk.android:answers:1.1.2
|    |    \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
|    +--- io.fabric.sdk.android:fabric:1.3.0
|    \--- com.crashlytics.sdk.android:beta:1.1.2
|         \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.squareup.okhttp:okhttp:2.2.0
|    \--- com.squareup.okio:okio:1.2.0
+--- org.immutables:gson:1.1.3
|    \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.0
+--- com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1
+--- de.greenrobot:eventbus:2.4.0
+--- com.github.chrisbanes.photoview:library:1.2.3
|    \--- com.android.support:support-v4:19.+ -> 22.1.1 (*)
+--- com.twitter:twitter-text:1.6.1
|    \--- org.yaml:snakeyaml:1.12
+--- project :innbxtextview
|    \--- com.android.support:appcompat-v7:22.1.1 (*)
+--- project :SwipeCards
+--- project :viewpagerindicator
|    \--- com.android.support:support-v4:22.1.1 (*)
+--- project :PagerStrip
|    +--- com.android.support:support-v4:22.1.1 (*)
|    \--- project :innbxtextview (*)
+--- project :fab
|    \--- com.android.support:support-annotations:22.1.1
\--- project :slidingup
     +--- com.android.support:support-v4:22.1.1 (*)
     \--- com.nineoldandroids:library:2.4.0

debugApk - Classpath packaged with the compiled 'debug' classes.
No dependencies

debugCompile - Classpath for compiling the debug sources.
\--- com.squareup.leakcanary:leakcanary-android:1.3
     \--- com.squareup.leakcanary:leakcanary-analyzer:1.3
          +--- com.squareup.haha:haha:1.1
          \--- com.squareup.leakcanary:leakcanary-watcher:1.3

debugProvided - Classpath for only compiling the debug sources.
No dependencies

debugWearApp - Link to a wear app to embed for object 'debug'.
No dependencies

default - Configuration for default artifacts.
No dependencies

default-mapping - Configuration for default mapping artifacts.
No dependencies

io.fabric - fabric and its transitive dependencies.
No dependencies

provided - Classpath for only compiling the main sources.
No dependencies

releaseApk - Classpath packaged with the compiled 'release' classes.
No dependencies

releaseCompile - Classpath for compiling the release sources.
\--- com.squareup.leakcanary:leakcanary-android-no-op:1.3
     \--- com.squareup.leakcanary:leakcanary-watcher:1.3

releaseProvided - Classpath for only compiling the release sources.
No dependencies

releaseWearApp - Link to a wear app to embed for object 'release'.
No dependencies

testApk - Classpath packaged with the compiled 'test' classes.
No dependencies

testCompile - Classpath for compiling the test sources.
No dependencies

testDebugApk - Classpath packaged with the compiled 'testDebug' classes.
No dependencies

testDebugCompile - Classpath for compiling the testDebug sources.
No dependencies

testDebugProvided - Classpath for only compiling the testDebug sources.
No dependencies

testDebugWearApp - Link to a wear app to embed for object 'testDebug'.
No dependencies

testProvided - Classpath for only compiling the test sources.
No dependencies

testReleaseApk - Classpath packaged with the compiled 'testRelease' classes.
No dependencies

testReleaseCompile - Classpath for compiling the testRelease sources.
No dependencies

testReleaseProvided - Classpath for only compiling the testRelease sources.
No dependencies

testReleaseWearApp - Link to a wear app to embed for object 'testRelease'.
No dependencies

testWearApp - Link to a wear app to embed for object 'test'.
No dependencies

wearApp - Link to a wear app to embed for object 'main'.
No dependencies

BUILD SUCCESSFUL

Total time: 4.434 secs

update: after performing Build->Clean Project it finally appeared :)

Alright, that's weird. Well, let's close then.

interesting, i'm noticing this same issue with one of my projects. as is someone else on SO :P http://stackoverflow.com/questions/30158104/square-leakcanary-cannot-find-symbol. my guess was some gradle foo that was stripping it out. odd though that the analyzer and watcher dependencies show up.

Oddly, just as i looked at this and ran a Build > Clean Project, it started appearing again. I could have _sworn_ this didn't work before. oh well... i did try it out at 2am in the morning. that could have been the problem. though, i'm curious to know what about the dependencies got the project to that state.

arr. actually i was looking at a different project ><. still running into the issue where leakcanary-android dependency not showing up.

Are you sure you are not using another variant than debug or release?

Same issue as Kaushik and other people on S.O.

Here's the setup for that project (where i'm noticing the issue):

List of Variants in the project:

  • debug
  • release
  • debugTest

Gradle version 2.1
Android plugin version 1.0.0
Android studio version 1.2.1.1

I notice that the gradle version(s) on this project are super old. Not sure if that's causing any issues (i'm a complete groovy/gradle newb so can't tell).

Another thing i notice that's a little different about this project is that i use multiple independent java subProjects (but doubt that should have to do with anything).

After doing a clean project build, i only notice the watcher and analyzer as seen below:

screen shot 2015-05-11 at 10 20 31 am

just wanted to say that i had the same problem. No matter what i do, no om.squareup.leakcanary.LeakCanary available, but after i cleaned the project in the build menu in Android Studio, it worked.

@eikaramba can you post the specifics (as i did in a previous comment) of your environment and project. that might help fish out the problem. i (and some other folks on SO) tried the Build->Clean Project and it didn't work.

i'm beginning to think this is a gradle versioning problem possibly :S but upping the version doesn't seem like a 10 minute task for my current project; so having more details would be helpful before i embark on alternative routes (especially given that the build > clean solution is not working for everyone).

sure,

List of Variants in the project:

release

Gradle version 2.4
Android plugin version (where do i see that? com.android.tools.build:gradle:1.2.3?)
Android studio version 1.2.1.1

I've tried everything (I think) but still no luck. I've clean the project many times but that has no effect.

@RobertoIDL Can you provide the gradle version + android plug version + android studio version?

@pyricau Sure!

Gradle version: 2.2.1
Android plugin version: com.android.tools.build:gradle:1.2.3
Android Studio: 1.2.1

I just encountered the same issue. Finally I solved it by adding

repositories {
    mavenCentral()
}

Before the dependencies { ... } section of my build.gradle.

@timrau just tried that solution and didn't work. sure it was not a red herring for another issue? ( i already had mavenCentral declared in the repositories section. tried removing other declarations to see if there was any conflict etc. didn't seem to have an effect)

@kaushikgopal I'm not pretty sure indeed.

@kaushikgopal @RobertoIDL what error do you get when building from the command line?

So the thing is, there's no "error" per say. it's just that the dependencies aren't getting pulled down properly.

I realize i haven't clearly explained the issue anywhere. so i'll paste down my steps in detail here:

  1. I check installation instructions from the README.md
  2. I diligently paste below lines in the dependencies block of my app's build.gradle

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

  1. i clean and build the project. no errors! all good.
  2. i open up my custom App class, and try to paste the below line

LeakCanary.install(this);

  1. Android Studio can't find LeakCanary anywhere.
  2. So i think to myself that's super strange, i could have sworn i saw a leakcanary package from square being pulled down. I check to see the external libs pulled down and notice only leakcanary-analyzer-1.3 and leakcanary-watcher-1.3 but NO leakcanary-android-1.3 (as shown in both my screenshot and @zaur 's first screenshot)

It's crazy cause on multiple greenfield projects that i've tried, everything gets pulled down without any issues. There's some setting or instruction that's "conflicting" with the existing project, that's preventing the leakcanary-android-1.3 jar alone from being pulled down. That's the part i can't seem to understand as i think there's probably some funkiness with groovy/gradle?

(if that's not the info you're looking for, do let me know and i'll add in more details).

I had this problem as well. What did solve the problem is the end was removing this from gradle:

configurations.all {
    transitive = false
}

hey @mvarnagiris ; would it be possible for you to change transitive = true and reproduce the same problem as mentioned in this thread?

for what it's worth, i don't have that setting in my gradle file :S (would be interesting to check the default).

With transitive = true it works fine. The problem is when I set transitive = false. I can reproduce this. Although it might be different issue. I get leakcanary-android-1.3 in my External Libraries list, but not other, so I get RefWatcher is missing error.

Yep that's the opposite error.

@kaushikgopal what's the output of ./gradlew :YOUR_MODULE:dependencies ?

had this issue too. but for me Build > Clean Project fixed it. for now.

this is strange. I got it to work now:

  • I basically knocked off a bunch of dependencies from my build.gradle
  • AS then threw up with errors for the missing dependencies
  • i re-added the dependencies (in the exact same order without any change)
  • but i went to command line and did a gw clean assemble

i see leakcanary-android now ! #win.

I'm not sure how or what changed, probably the clean build from command line flushes out some cached config :S ? In any case solved for me. Thanks folks!

@RobertoIDL give a shot and clean build from command line (alternatively the unexplainable crazy procedure i just listed above) and see if it works for you.

In my case, I had a custom buildType

buildTypes {
    bypass {
       // Some parameters
    }
}

I just had to use bypassCompile instead of debugCompile

Hi @kaushikgopal I've just tried but no luck.

I'll keep investigating tomorrow, this shouldn't be this difficult :)

At least you got it working.

Alright. Anyone else than @RobertoIDL still have that problem?

another observation: AS doesn't show the dependency sometimes, but that doesn't necessarily mean it's not there :). so try a clean build from command line and run the dependencies command to see if it's really not present.

This happening because leakcanary-android is aar, and "External Libraries" only shows jar's.
You can find leakcanary in build/intermediates/exploded-aar/com.squareup.leakcanary/leakcanary-android

yup that makes sense. though previously (without the clean build command line dance) it was not available in the exploded-aar folder either (cause the class LeakCanary was not found at all).

@kaushikgopal did you do gradle sync after you changed your gradle file? (Tools -> Android -> Sync project with Gradle Files)

yup i do remember doing that as well. usually AS is pretty annoying about
wanting to sync if you make any changes to the gradle file.

Kaushik

On Thu, May 14, 2015 at 3:28 PM, Vladimir Baryshnikov <
[email protected]> wrote:

@kaushikgopal https://github.com/kaushikgopal did you do gradle sync
after you changed your gradle file? (Tools -> Android -> Sync project with
Gradle Files)

—
Reply to this email directly or view it on GitHub
https://github.com/square/leakcanary/issues/9#issuecomment-102187599.

Hi all,

I got it working, not how I wanted but at least is working now. Let me explain the differences between my project and probably how everyone else is doing it.

I have my app module and then another module called libraries where I have all the libraries that are not gradle compatible or that I have developed for this particular project.

So my gradle settings file looks like this (I've changed some names):

include ':app'
include ':libraries:volley'
include ':libraries:barcodeLibrary'
include ':libraries:baseAndroidLibrary'
include ':libraries:coreLibrary'

I was trying to add the LeakCanary library to my baseAndroidLibrary and no matter what I try it doesn't work, I never get all the dependencies downloaded.

If instead I add the library to my app's gradle file after a simple clean project everything is there.

For the moment I will leave it as part of the app module as it's working but ideally I would like to have as part of my baseAndroidLibrary.

Thank you all for your help.

Alright. All problems fixed then. Looks like https://github.com/square/leakcanary#troubleshooting is all that's needed.

Hi all,
Can you help me in setting up leakCanary with my custom Build type , what all has to be done.

If you have custom built type, add this too: customBuildTypeCompile 'com.squareup.leakcanary:leakcanary-android:x.x.x'

i just change this the import : com.squareup.leakcanary.LeakCanary(cannot symbol class) to com.squareup.leakcanary.*;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edgelv34 picture edgelv34  Â·  7Comments

divyenduz picture divyenduz  Â·  6Comments

devism picture devism  Â·  6Comments

matejdro picture matejdro  Â·  6Comments

SUPERCILEX picture SUPERCILEX  Â·  4Comments