问题描述
我对R8有问题.在MyLib
中,我具有受保护的方法的公共摘要MyLibsClass
. MyChildClass
从MyApp
中的MyLibsClass
扩展,并且在R8的魔力作用下,MyLibsClass
中的所有受保护的方法(包括受保护的抽象)都被更改为公共方法,并且在MyChildClass
中,我当然收到了"attempting to assign weaker access privileges ('protected'); was 'public')
的问题,试图覆盖受保护的抽象方法.
I have an issue with R8. In MyLib
I have public abstract MyLibsClass
in which I have protected methods. MyChildClass
extends from MyLibsClass
in MyApp
and after R8's magic all protected methods (including protected abstract) in MyLibsClass
are changed into public ones, and of course in MyChildClass
I'm getting "attempting to assign weaker access privileges ('protected'); was 'public')
issue as trying to override protected abstract methods.
其他信息
MyLib的build.gradle
MyLib's build.gradle
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
proguard-rules.pro
proguard-rules.pro
-keep class com.example.mylib.*{
public protected *; }
-keep class com.example.mylib.*$*{
public protected *; }
有人遇到这种问题或知道解决此问题的方法吗?
Anyone had this kind of issue or know a way to fix this?
推荐答案
因此,根据讨论在此处,
在默认的Proguard设置中启用了
as allowAccessModification
,该设置位于Android SDK (\Android\Sdk\tools\proguard\proguard-android-optimize.txt)
中,我的错误是将其用于我的库.
as allowAccessModification
is enabled in default proguard settings, which is located in Android SDK (\Android\Sdk\tools\proguard\proguard-android-optimize.txt)
and my mistake was using this for my libraries.
因此,如果有人遇到相同的问题,我建议为proguard
创建您自己的基本配置文件,并将过去的整个默认配置(不带"allowAccessModification"
)复制到其中.
So if anyone has the same issue I will suggest to create your own base config file for proguard
and copy past whole default configs without "allowAccessModification"
into it.
如果还有人对此感兴趣,您可以跟踪此问题.希望将为附近功能中的库获取单独的配置文件.
Also if someone interested more, you can track this issue. Hopefully will get separate config file for libraries in near feature.
这篇关于R8改变了“受保护"的状态.抽象类“公开"的方法.没有-allowaccessmodification标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!