Getting “EnclosingMethod” errors on building in Android Studio 2

假装没事ソ 提交于 2019-11-28 11:52:48

Update 2016/09/19

This is fixed in LeakCanary 1.4, so simply upgrading should fix it without needing to mess with an alternate version of haha.

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4'

Previously

These warnings are caused by haha:2.0.2, which is a dependency of leakcanary-android:1.4-beta2.

It's fixed in haha:2.0.3, so you can fix it by explicitly using the newer version in your dependencies. Add this line for each flavor where you are adding a leakcanary dependency. You don't need to add it for leakcanary-android-no-op, since it has no dependencies.

debugCompile 'com.squareup.haha:haha:2.0.3'

Adding

-keepattributes EnclosingMethod

to proguard's configuration file (in my case, proguard.cfg) seems to have fixed this.

I was getting same error. It seems there was some problem with leakcanary (in my case). I tried following changes in proguard file.

-dontwarn com.squareup.haha.guava.**
-dontwarn com.squareup.haha.perflib.**
-dontwarn com.squareup.haha.trove.**
-dontwarn com.squareup.leakcanary.**
-keep class com.squareup.haha.** { *; }
-keep class com.squareup.leakcanary.** { *; }

# Marshmallow removed Notification.setLatestEventInfo()
-dontwarn android.app.Notification

I am not getting those issue anymore. Here is the link

I solved the issue by adding following dependency to my build.gradle:

testCompile "com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2"

here is link:https://github.com/square/leakcanary/issues/491

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!