LeakCanary生成失败,生成类型不是调试或发布

时间:2018-10-19 15:27:04

标签: android gradle android-gradle leakcanary

我的Android应用具有第三种构建类型“ qa”。我遵循了LeakCanary网站上的这些说明:“如果您有除调试和发布以外的其他构建类型,则还需要为其添加特定的依赖项(xxxCompile)”:

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

这会导致gradle同步错误:

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.

如果我做qaCompile,也会发生同样的情况。这是我的构建类型:

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
        }
    }

说明似乎很简单,所以我看不到我可能会缺少的内容。任何人都有使该设置生效的经验吗?

1 个答案:

答案 0 :(得分:1)

正如作者所说的那样正确-添加带有buildType前缀的实现。

例如,我有一个名为releaseFreemium的自定义buildType。它从构建类型(发布)获取所有设置,而没有其他选项。

更多信息,请点击https://developer.android.com/studio/build/build-variants

enter image description here enter image description here

有关LeakCanary(https://github.com/square/leakcanary/wiki/FAQ#how-do-i-fix-build-errors)的常见问题解答。

相关问题