programing

Proguard 문제 "경고 : 익명 내부 클래스에 대한 InnerClasses 속성 무시"

projobs 2021. 1. 19. 20:56
반응형

Proguard 문제 "경고 : 익명 내부 클래스에 대한 InnerClasses 속성 무시"


이 문제를 어떻게 설명 할 수 있는지 모르겠습니다. 검색을 많이했지만 해결책을 찾지 못했습니다.

또한이 솔루션은 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;
    }
}

그리고 jar 폴더에는 ormlite-android-4.48.jarormlite-core-4.48.jar.

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.**

오류 기록:

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.

나머지 오류 로그 :

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)

추가 시도

-keepattributes InnerClasses
-dontoptimize

ProGuard 구성에. 그러면 문제가 해결됩니다.

호환되지 않는 최적화가 적용되었을 가능성이 있습니다 (오류 로그의 마지막 줄을 유발할 수 있음).

최적화를 허용하려면 다음을 사용하여 최적화 구성을 미세 조정해야합니다.

-optimizations optimization_filter 

ProGuard 구성의 옵션.


proguard-rules.pro 파일에이 줄을 추가하면 문제가 해결되었습니다.

-keepattributes EnclosingMethod
-keepattributes InnerClasses

나는 제안한다 -dontwarn InnerClasses


이 문제의 원인은 proguard-android.txt 파일이이 문제를 방지하기위한 올바른 구성을 포함하고 있기 때문에 프로젝트에서 참조되지 않는 경우입니다.

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

해결책

이 파일을 자신의 ProGuard 구성 파일과 함께 프로젝트에 추가해야합니다. 예를 들면 다음과 같습니다.

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

이 파일은 SDK에 포함되어 있으므로 gradle 빌드에서 자동으로 선택하므로 프로젝트에 복사 할 필요가 없습니다.


여기에 두 가지 문제가 있습니다.

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

경고 일뿐입니다. 코드가 제대로 작동하면 .gradle파일 에서 Lint를 비활성화하여 무시할 수 있습니다 .

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

이것은 ProGuard가 변수 할당을 최적화하는 것처럼 보이지만 잘못 수행합니다.

ProGuard 파일에 아래 줄을 추가하여이 최적화를 비활성화하십시오.

-optimizations !code/allocation/variable


dex.force.jumbo=truegradle.properties에 추가 하십시오. 그것은 나를 위해 작동합니다.


나를 위해 문제를 해결 한 것은 최신 버전의 jar를 사용하는 것이 었습니다. 단서는 다음과 같습니다.

이 클래스는 최신 .class 파일 형식을 대상으로하지 않는 컴파일러에서 생성되었을 수 있습니다. 권장되는 솔루션은 최신 컴파일러를 사용하여 소스에서 클래스를 다시 컴파일하는 것입니다.

그래서 나는 다음과 같이 변경했습니다.

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

에:

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

컴파일 SDK, 대상 SDK 버전 및 지원 라이브러리 버전을 업데이트하여 유사한 문제를 해결했습니다.

참조 URL : https://stackoverflow.com/questions/35796144/proguard-issue-warningignoring-innerclasses-attribute-for-an-anonymous-inner-c

반응형