Получение ошибок EnclosingMethod при сборке в Android Studio 2

Я получаю следующие ошибки сборки, когда запускаю приложение в Android Studio 2. Этих ошибок не было, когда я использовал более раннюю версию Android Studio.

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.base.Joiner$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$2) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$3) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.

Что это за ошибки и как их решить? Кроме того, apk работает нормально, и приложение также отлично работает.


person Amit Tiwari    schedule 21.04.2016    source источник
comment
ты пробовал очистить-›перестроить   -  person Lokanath    schedule 21.04.2016
comment
@Lokanath да, я уже пробовал.   -  person Amit Tiwari    schedule 21.04.2016
comment
Получил решение отсюда при поиске проблемы: stackoverflow.com/a/36523016/1263362   -  person Sayem    schedule 20.09.2016
comment


Ответы (4)


Обновление 2016/09/19

Это исправлено в LeakCanary 1.4, поэтому простое обновление должно исправить это без необходимости возиться с альтернативной версией haha.

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

Ранее

Эти предупреждения вызваны haha:2.0.2, который является зависимостью leakcanary-android:1.4-beta2.

Это исправлено в haha:2.0.3, поэтому вы можете исправить это, явно используя более новую версию в своих зависимостях. Добавьте эту строку для каждого варианта, в который вы добавляете зависимость leakcanary. Вам не нужно добавлять его для leakcanary-android-no-op, так как он не имеет зависимостей.

debugCompile 'com.squareup.haha:haha:2.0.3'
person Sky Kelsey    schedule 07.07.2016
comment
Это самый простой способ избавиться от этого раздражающего предупреждения. Спасибо - person Oleksandr; 13.07.2016

Добавление

-keepattributes EnclosingMethod

в файле конфигурации proguard (в моем случае proguard.cfg), похоже, это исправлено.

person fattire    schedule 24.08.2016
comment
Отладочные сборки обычно не собираются с proguard (потому что это занимает так много времени, поэтому в большинстве конфигураций его нет).. но я полагаю, что это должно... - person fattire; 11.11.2016

Я получал ту же ошибку. Кажется, была какая-то проблема с Leakcanary (в моем случае). Я попытался внести следующие изменения в файл proguard.

-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

Я больше не получаю эти проблемы. Вот ссылка

person Abhishek Patidar    schedule 02.05.2016

Я решил проблему, добавив следующую зависимость в свой build.gradle:

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

вот ссылка: https://github.com/square/leakcanary/issues/491

person Miceking    schedule 04.05.2016