我在我的项目中遇到了这个异常:
No pending exception expected: java.lang.IllegalAccessError: com.mogujie.mgjpfbasesdk.fragment.PFBaseFragment
06-28 20:36:33.834 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class dalvik.system.DexFile.defineClassNative(java.lang.String, java.lang.ClassLoader, java.lang.Object) (DexFile.java:-2)
06-28 20:36:33.834 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class dalvik.system.DexFile.defineClass(java.lang.String, java.lang.ClassLoader, java.lang.Object, java.util.List) (DexFile.java:226)
06-28 20:36:33.834 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class dalvik.system.DexFile.loadClassBinaryName(java.lang.String, java.lang.ClassLoader, java.util.List) (DexFile.java:219)
06-28 20:36:33.834 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class dalvik.system.DexPathList.findClass(java.lang.String, java.util.List) (DexPathList.java:338)
06-28 20:36:33.834 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:54)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:511)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:469)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class java.lang.Class.classForName!(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:324)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Class java.lang.Class.forName(java.lang.String) (Class.java:285)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.String com.mogujie.commanager.MGJComManager.onIntentInterceptedInternal(java.lang.String, android.content.Intent) (MGJComManager.java:114)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.String com.mogujie.commanager.MGJComManager$MGJHmInterceptor.activity(java.lang.String, android.content.Intent) (MGJComManager.java:140)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void com.mogujie.commanager.internal.hack.MGJHDelegate.handleActivity(android.os.Message) (MGJHDelegate.java:316)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at boolean com.mogujie.commanager.internal.hack.MGJHDelegate.handleMessage(android.os.Message) (MGJHDelegate.java:148)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:98)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void android.os.Looper.loop() (Looper.java:148)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:5417)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:726)
06-28 20:36:33.835 13192-13192/com.mogujie.uni A/art: art/runtime/thread.cc:1321] at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:616)
我的目标 api 是 23;
我的构建工具是 classpath 'com.android.tools.build:gradle:1.5.0'
导致这种情况的 aar 正在使用 dagger、rxjava 和 otto。因此,寄存器功能适用于 otto。
我该如何解决
更让我困惑的是,我在 6.0 设备上运行这个应用程序,但异常发生在 dalvik.system 包中
更重要的是,我检查了我的 apk 中的 dex 文件。可以看出,之前添加的两个aar在同一个dex文件中,即我项目中的第二个dex文件(我使用google的multidex工具将我的应用拆分为multidexes)