从27.1.1版本升级到v28.0.0 Android支持库后,我的构建失败,但出现以下异常:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'
原因:
Warning: androidx.media.AudioAttributesCompatParcelizer: can't find referenced field 'android.support.v4.media.AudioAttributesImpl mImpl' in program class android.support.v4.media.AudioAttributesCompat
Warning: androidx.media.AudioAttributesImplApi21Parcelizer: can't find referenced field 'android.media.AudioAttributes mAudioAttributes' in program class android.support.v4.media.AudioAttributesImplApi21
Warning: androidx.media.AudioAttributesImplApi21Parcelizer: can't find referenced field 'int mLegacyStreamType' in program class android.support.v4.media.AudioAttributesImplApi21
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mUsage' in program class android.support.v4.media.AudioAttributesImplBase
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mContentType' in program class android.support.v4.media.AudioAttributesImplBase
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mFlags' in program class android.support.v4.media.AudioAttributesImplBase
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mLegacyStream' in program class android.support.v4.media.AudioAttributesImplBase
我尝试添加
-keep class android.support.v4.media.** { *; }
到我的Gradle配置,但错误仍然存在。
任何人都可以提供帮助吗?
谢谢
乔什
答案 0 :(得分:0)
我不知道这是否是最好的解决方案,但是将这些行添加到我的proguard-rules.pro文件之后,它可以解决问题:
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }