VerifyError:拒绝类android.support.g.b,因为它在编译时验证失败 [英] VerifyError: Rejecting class android.support.g.b because it failed compile-time verification
问题描述
这类似于拒绝类,因为它无法编译- Android时间验证和 java.lang.VerifyError:使用发行版APK时,验证程序拒绝了Lollipop上的类,但是问题的根源仍然未知,所有提出的解决方案都无济于事.
This is similar to Rejecting class because it failed compile-time verification Android and java.lang.VerifyError: Verifier rejected class on Lollipop when using release APK but the origin of my problem is still unknown and all the proposed solutions do not help.
手动安装具有MultiDex支持并启用ProGuard的签名发行版APK会在启动时引发此异常:
Manually installing a signed release apk with MultiDex support and ProGuard enabled throws this exception on start:
475-475/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: ..., PID: 475
java.lang.VerifyError: Verifier rejected class android.support.g.b due to bad method void android.support.g.b.<init>() (declaration of 'android.support.g.b' appears in /data/app/...-2/base.apk)
at ...MyApp.attachBaseContext(Unknown Source)
at android.app.Application.attach(Application.java:181)
-dontoptimize
不会发生这种情况.当前的最小优化设置:
This will not happen with -dontoptimize
. Current minimal optimization setting:
-optimizations "code/*"
在没有-optimizations
或限制性较小的选项的情况下,我会遇到相同的错误.添加-keep class android.*
也无济于事.我没有遇到"code/removal/*,code/simplification/*"
错误,但这会忽略-assumenosideeffects
I get the same error without -optimizations
or with less restrictive options. Adding -keep class android.*
wont help either. I get no error with "code/removal/*,code/simplification/*"
, but this ignores -assumenosideeffects
android.support.g.b是混淆的android.support.multidex.MultiDex类本身,并且在调用覆盖的attachBaseContext(Context)
时引起错误:
android.support.g.b is the obfuscated android.support.multidex.MultiDex class itself, and the error is caused when the overridden attachBaseContext(Context)
is called:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
使用字节码查看器对该方法(默认构造函数)进行解码会导致:
Decoding this method (the default constructor) with the byte code viewer results in:
private b() { // <init> //()V
return
}
- 通过类规范禁用优化将很有用.
- 替代方法:知道考虑
-assumenosideeffects
的最小 - It would be useful to disable optimization by class specification.
- Alternative: Knowing the minimum
-optimizations
option that considers-assumenosideeffects
-optimizations
选项
推荐答案
请勿将成员通配符与-assumenosideeffects
一起使用,因为这将溢出"到其他类的Object.参见 https://sourceforge.net/p/proguard/bugs/716/#98d4
Do not use member wildcards with -assumenosideeffects
because this will "spill over" to Object for other classes. See https://sourceforge.net/p/proguard/bugs/716/#98d4
任何带有接口的规则都可能出现类似的问题.示例:
Similar problems may come up for any rules with interfaces. Example:
-assumenosideeffects class * implements Interface {
public <init>();
public Object interfacemethod(); # May concern methods with same signature in other Objects
}
这篇关于VerifyError:拒绝类android.support.g.b,因为它在编译时验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!