已按照 Github 的说明配置了 build.gradle。似乎未包含 LeakCanary 类。
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
分析器和监视器包中只有一个单独的类文件。
已按照 Github 的说明配置了 build.gradle。似乎未包含 LeakCanary 类。
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
分析器和监视器包中只有一个单独的类文件。
对我来说,重建项目解决了它。
有一个被删除的答案(我不知道为什么)由Kaushik Gopal提供了这个解决方案,并指向Github问题
我很惊讶
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
如果对您没有用,请尝试更改构建类型而非产品风味:
这可能与您的构建类型有关,您可以尝试更换构建类型而非产品风味:
dependencies {
someBuildTypeCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
}
Make sure you add the libraries to your build.gradle
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
add mavenCentral()
to your repositories
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
@aar
以便让gradle专门寻找aar库,而不是jar(我在Maven中遇到了这个问题,添加<type>aar</type>
似乎有所帮助)。我遇到了类似的问题。当继承Application时,您不应该使用相同的类名LeakCanary。
我已经更改了以下代码:
public class LeakCanary extends Application { }
到
public class MainController extends Application { }
让它完成。
<<BUILDTYPE>>Implementation
似乎是有效的: dependencies {
mybuildtypeImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
}
在我的Gradle构建类型块中,我有多个构建类型。我为我的构建类型添加了单独的实现,并且它对我起作用了。例如,如果您除了debug和release之外还有其他构建类型,请尝试
dependencies {
yourCustomBuildTypeImplementation 'com.squareup.leakcanary:leakcanary-android:version'
}