nasch
nasch

Reputation: 5498

LeakCanary build fails with build type that is not debug or release

My Android app has a third build type "qa". I followed these instructions from LeakCanary's site: "if you have other build types than debug and release, you need to add a specific dependency for those too (xxxCompile)":

qaImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'

This results in a gradle sync error:

Could not find method qaImplementation() for arguments [com.squareup.leakcanary:leakcanary-android-no-op:1.6.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

The same happens if I do qaCompile. Here are my build types:

buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix " Dev"
        }
        qa {
            zipAlignEnabled true
            signingConfig signingConfigs.releaseConfig
            versionNameSuffix " Test"
        }
        release {
            signingConfig signingConfigs.releaseConfig
            zipAlignEnabled true
        }

        flavorDimensions "app" // Required by Gradle 3

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

The instructions seem totally straightforward so I don't see what I might be missing. Anyone have experience getting this setup to work?

Upvotes: 5

Views: 1720

Answers (1)

deadfish
deadfish

Reputation: 12304

Correct, as the author said - add implementation with prefix of buildType.

For example, I have custom buildType called releaseFreemium. It takes all settings from build type - release - without additional options.

More info here https://developer.android.com/studio/build/build-variants .

enter image description here enter image description here

Answer in FAQ of LeakCanary (https://github.com/square/leakcanary/wiki/FAQ#how-do-i-fix-build-errors).

Upvotes: 4

Related Questions