web-dev-qa-db-fra.com

Problème "Attention: Ignorer l'attribut InnerClasses pour une classe interne anonyme"

Je ne sais pas comment je peux décrire ce problème. J'ai beaucoup cherché, mais je n'ai trouvé aucune solution.

Aussi cette solution ne m'a pas aidé -keepattributes EnclosingMethod :

dependencies {
    compile project(':libraries:material-drawer')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.Android.support:appcompat-v7:23.2.0'
    compile 'com.Android.support:recyclerview-v7:23.2.0'
    compile 'com.Android.support:design:23.2.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.viewpagerindicator:viewpagerindicator:2.4.3'
    compile('com.github.afollestad.material-dialogs:commons:0.8.5.6@aar') {
        transitive = true
    }
    compile('com.crashlytics.sdk.Android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}

Et le dossier jar contient ormlite-Android-4.48.jar et ormlite-core-4.48.jar.

Fichier Proguard:

-keepattributes EnclosingMethod
-dontobfuscate

-keep public class * extends Android.support.v4.view.ActionProvider {
    public <init>(Android.content.Context);
}

-dontwarn Android.support.v4.**

#FOR APPCOMPAT 23.1.1:
-keep class !Android.support.v7.view.menu.*MenuBuilder*, Android.support.v7.** { *; }
-keep interface Android.support.v7.* { *; }

# Required for crashlytics
#-keep class com.crashlytics.** { *; }
#-keep class com.crashlytics.Android.**

-keepattributes SourceFile,LineNumberTable,*Annotation*

# Required for eventbus
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keepclassmembers class ** {
    public void onEvent*(**);
}

# OrmLite uses reflection
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }

# Keep the helper class and its constructor
-keep class * extends com.j256.ormlite.Android.apptools.OrmLiteSqliteOpenHelper
-keepclassmembers class * extends com.j256.ormlite.Android.apptools.OrmLiteSqliteOpenHelper {
  public <init>(Android.content.Context);
}

# Keep all model classes that are used by OrmLite
# Also keep their field names and the constructor
-keep @com.j256.ormlite.table.DatabaseTable class * {
    @com.j256.ormlite.field.DatabaseField <fields>;
    @com.j256.ormlite.field.ForeignCollectionField <fields>;
}

-keep public class org.codehaus.**
-keep public class Java.nio.**

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# Gson specific classes
-keep class Sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.packagename.database.tables.** { *; }
-keep class com.packagename.models.apidata.** { *; }
-keep class com.packagename.models.data.** { *; }

## Nineolddroid related classes to ignore

-keep class com.nineoldandroids.animation.** { *; }
-keep interface com.nineoldandroids.animation.** { *; }
-keep class com.nineoldandroids.view.** { *; }
-keep interface com.nineoldandroids.view.** { *; }

-dontwarn okio.**

Journal d'erreur:

Warning:Ignoring InnerClasses attribute for an anonymous inner class
this warning is that reflective operations on this class will incorrectly
(Android.support.v4.app.FragmentTransitionCompat21$1) that doesn't come with an
(Android.support.v4.view.accessibility.AccessibilityNodeProviderCompatJellyBean$1) that doesn't come with an
Warning:Ignoring InnerClasses attribute for an anonymous inner class
indicate that it is *not* an inner class.
Warning:Ignoring InnerClasses attribute for an anonymous inner class
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
(Android.support.v4.view.ViewPropertyAnimatorCompatJB$1) that doesn't come with an
and without specifying any "-target" type options. The consequence of ignoring
(io.fabric.sdk.Android.services.common.ExecutorUtils$1) that doesn't come with an
compiler that did not target the modern .class file format. The recommended
Warning:Ignoring InnerClasses attribute for an anonymous inner class
associated EnclosingMethod attribute. This class was probably produced by a
solution is to recompile the class from source, using an up-to-date compiler
compiler that did not target the modern .class file format. The recommended
compiler that did not target the modern .class file format. The recommended
(Android.support.v4.view.accessibility.AccessibilityNodeProviderCompatKitKat$1) that doesn't come with an
indicate that it is *not* an inner class.
this warning is that reflective operations on this class will incorrectly
and without specifying any "-target" type options. The consequence of ignoring
(Android.support.v4.view.AccessibilityDelegateCompatIcs$1) that doesn't come with an
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
(Android.support.v4.app.FragmentTransitionCompat21$3) that doesn't come with an
solution is to recompile the class from source, using an up-to-date compiler
indicate that it is *not* an inner class.
solution is to recompile the class from source, using an up-to-date compiler
compiler that did not target the modern .class file format. The recommended
this warning is that reflective operations on this class will incorrectly
associated EnclosingMethod attribute. This class was probably produced by a
Warning:Ignoring InnerClasses attribute for an anonymous inner class
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
associated EnclosingMethod attribute. This class was probably produced by a
indicate that it is *not* an inner class.
Warning:Ignoring InnerClasses attribute for an anonymous inner class
indicate that it is *not* an inner class.
(Android.support.v4.view.ViewPropertyAnimatorCompatKK$1) that doesn't come with an
and without specifying any "-target" type options. The consequence of ignoring
Warning:Ignoring InnerClasses attribute for an anonymous inner class
solution is to recompile the class from source, using an up-to-date compiler
this warning is that reflective operations on this class will incorrectly
solution is to recompile the class from source, using an up-to-date compiler
associated EnclosingMethod attribute. This class was probably produced by a
Warning:Ignoring InnerClasses attribute for an anonymous inner class
(Android.support.v4.view.ViewPropertyAnimatorCompatICS$1) that doesn't come with an
(Android.support.v4.app.FragmentTransitionCompat21$4) that doesn't come with an
solution is to recompile the class from source, using an up-to-date compiler
this warning is that reflective operations on this class will incorrectly
this warning is that reflective operations on this class will incorrectly
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
(Android.support.v4.app.FragmentTransitionCompat21$2) that doesn't come with an
indicate that it is *not* an inner class.
this warning is that reflective operations on this class will incorrectly
compiler that did not target the modern .class file format. The recommended
indicate that it is *not* an inner class.
solution is to recompile the class from source, using an up-to-date compiler
compiler that did not target the modern .class file format. The recommended
and without specifying any "-target" type options. The consequence of ignoring
and without specifying any "-target" type options. The consequence of ignoring
indicate that it is *not* an inner class.
this warning is that reflective operations on this class will incorrectly
compiler that did not target the modern .class file format. The recommended
Warning:Ignoring InnerClasses attribute for an anonymous inner class
this warning is that reflective operations on this class will incorrectly
compiler that did not target the modern .class file format. The recommended
Warning:Ignoring InnerClasses attribute for an anonymous inner class
indicate that it is *not* an inner class.
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
associated EnclosingMethod attribute. This class was probably produced by a
indicate that it is *not* an inner class.
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
Warning:Ignoring InnerClasses attribute for an anonymous inner class
this warning is that reflective operations on this class will incorrectly
(Android.support.v4.view.AccessibilityDelegateCompatJellyBean$1) that doesn't come with an
Warning:Ignoring InnerClasses attribute for an anonymous inner class
associated EnclosingMethod attribute. This class was probably produced by a
associated EnclosingMethod attribute. This class was probably produced by a
and without specifying any "-target" type options. The consequence of ignoring
(Android.support.v4.view.ViewCompatLollipop$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
solution is to recompile the class from source, using an up-to-date compiler
Warning:Ignoring InnerClasses attribute for an anonymous inner class
compiler that did not target the modern .class file format. The recommended
indicate that it is *not* an inner class.
this warning is that reflective operations on this class will incorrectly
Warning:Ignoring InnerClasses attribute for an anonymous inner class
indicate that it is *not* an inner class.
associated EnclosingMethod attribute. This class was probably produced by a
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
solution is to recompile the class from source, using an up-to-date compiler
associated EnclosingMethod attribute. This class was probably produced by a
(com.Android.volley.ExecutorDelivery$1) that doesn't come with an
solution is to recompile the class from source, using an up-to-date compiler
compiler that did not target the modern .class file format. The recommended
and without specifying any "-target" type options. The consequence of ignoring
associated EnclosingMethod attribute. This class was probably produced by a
and without specifying any "-target" type options. The consequence of ignoring
indicate that it is *not* an inner class.
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
indicate that it is *not* an inner class.
this warning is that reflective operations on this class will incorrectly
associated EnclosingMethod attribute. This class was probably produced by a
associated EnclosingMethod attribute. This class was probably produced by a
(io.fabric.sdk.Android.services.common.ExecutorUtils$2) that doesn't come with an
Warning:Ignoring InnerClasses attribute for an anonymous inner class
compiler that did not target the modern .class file format. The recommended
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
and without specifying any "-target" type options. The consequence of ignoring
Uncaught translation error: com.Android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type int using a local variable of type Android.support.design.widget.CoordinatorLayout$LayoutParams. This is symptomatic of .class transformation tools that ignore local variable information.

Reste du journal des erreurs:

Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.commit451/PhotoView/1.2.4/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.crashlytics.sdk.Android/crashlytics-core/2.3.8/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/commons/0.8.5.6/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.6/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.viewpagerindicator/viewpagerindicator/2.4.3/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/support-v4/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.4.0/5b72bf48563ea8410e650de14aa33ff69a3e8c35/okio-1.4.0.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.crashlytics.sdk.Android/answers/1.3.6/jars/classes.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.nineoldandroids/library/2.4.0/e9b63380f3a242dbdbf103a2355ad7e43bad17cb/library-2.4.0.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/io.fabric.sdk.Android/fabric/1.3.10/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.crashlytics.sdk.Android/crashlytics/2.5.5/jars/classes.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.4/695b63d702f505b9b916e02272e3b6381bade7f/gson-2.4.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.crashlytics.sdk.Android/beta/1.1.4/jars/classes.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.mcxiaoke.volley/library/1.0.19/a8f23f65fc1e522ee4a1a697ee569901a46741fa/library-1.0.19.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.5.2/7446d06ec8d4f7ffcc53f1da37c95f200dcb9387/picasso-2.5.2.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/recyclerview-v7/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.mikepenz/iconics/1.6.2/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/transforms/mergeJavaRes/release/jars/2/1f/main.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/AppName.libraries/material-drawer/unspecified/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/appcompat-v7/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/support-v4/23.2.0/jars/libs/internal_impl-23.2.0.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/support-vector-drawable/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/design/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.Android.support/animated-vector-drawable/23.2.0/jars/classes.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/com.mikepenz/iconics-core/1.6.2/jars/classes.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp/okhttp/2.4.0/40340c0748190fe897baf7bffbc1b282734294e5/okhttp-2.4.0.jar] (filtered)
  Copying resources from program jar [/home/ibrahim/.gradle/caches/modules-2/files-2.1/de.greenrobot/eventbus/2.4.0/ddd166d01b3158d1c00576d29f7ed15c030df719/eventbus-2.4.0.jar] (filtered)
  Copying resources from program jar [path/to/application/app/build/intermediates/exploded-aar/me.zhanghai.Android.materialprogressbar/library/1.1.4/jars/classes.jar] (filtered)
51
Ibrahim Disouki

Essayez d'ajouter

-keepattributes InnerClasses
-dontoptimize

à la configuration de ProGuard. Cela devrait résoudre le problème.

Il est probable que des optimisations incompatibles sont appliquées (ce qui provoque probablement la dernière ligne du journal des erreurs).

Si vous souhaitez autoriser les optimisations, il est nécessaire d’affiner les optimisations avec lesquelles vous configurez la configuration. 

-optimizations optimization_filter 

option dans ProGuard config.

58
Tomik

L'ajout de ces lignes au fichier proguard-rules.pro a résolu mon problème.

-keepattributes EnclosingMethod
-keepattributes InnerClasses
31

Je suggère -dontwarn InnerClasses

9
noomz

J'ai remarqué que la cause de ce problème est souvent due au fait que le fichier proguard-Android.txt n'est pas référencé dans le projet car il contient la configuration appropriée pour éviter ce problème:

# Preserve some attributes that may be required for reflection.
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod

Solution

Assurez-vous d’ajouter ce fichier à votre projet, ainsi que vos propres fichiers de configuration ProGuard, par exemple:

release {
    minifyEnabled true
    setProguardFiles([getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'])
}

Le fichier est contenu dans le SDK afin que votre compilation le récupère automatiquement. Vous n'avez pas besoin de le copier dans votre projet.

3
maciekjanusz

Vous avez 2 problèmes ici.

1) Warning:Ignoring InnerClasses attribute for an anonymous inner class ......

C'est juste un avertissement. Si votre code fonctionne correctement, vous pouvez l'ignorer en désactivant Lint dans le fichier .gradle:

Android {
    ...
    lintOptions {
        abortOnError false
    }
}

2) translation error: attempt to set or access a value of type int using a local variable of type Android.support.design.widget.CoordinatorLayout$LayoutParams

Cela ressemble à un endroit où ProGuard optimise l’allocation de variables, mais ne le fait pas correctement.

Essayez de désactiver cette optimisation en ajoutant la ligne ci-dessous dans votre fichier ProGuard:

-optimizations !code/allocation/variable

2
Oleg Cherr

Ajoutez dex.force.jumbo=true dans votre fichier gradle.properties. Ça marche pour moi.

1
Sanket Parchande

Pour moi ce qui a résolu le problème était d'utiliser une version plus récente de jar. L'indice était:

Cette classe a probablement été produite par un compilateur qui ne cible pas le format de fichier moderne .class. Le recommandé La solution consiste à recompiler la classe à partir du source, en utilisant un compilateur à jour.

Alors j'ai changé de:

    compile 'com.google.inject:guice:4.0'

à:

    compile 'com.google.inject:guice:4.2.0'
0
Uriel Frankel