Подтвердить что ты не робот

Получение ошибок "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 строит отлично, и приложение также отлично работает.

4b9b3361

Ответ 1

Обновление 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'

Ответ 2

Добавление

-keepattributes EnclosingMethod

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

Ответ 3

Я получал такую ​​же ошибку. Кажется, что была проблема с утечкой (в моем случае). Я пробовал следующие изменения в файле 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

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

Ответ 4

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

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

здесь ссылка: https://github.com/square/leakcanary/issues/491