Qihoo360 / RePlugin

RePlugin - A flexible, stable, easy-to-use Android Plug-in Framework
Apache License 2.0
7.25k stars 1.53k forks source link

java.lang.ExceptionInInitializerError求清晰解释 #847

Open asdf19910719 opened 5 years ago

asdf19910719 commented 5 years ago

问题详细描述 Detailed description of the problem

复现问题步骤 Steps to reproduce the problem

  1. gradle:4.6
  2. tools.build:gradle:3.2.1 3.问题如下,看了其他issue不是很明白,想问下能给个清晰的解释么?

其它重要信息 Other important information

replugin-host-lib/gradle Version:2.3.2' rePlugin-plugin-lib/gradle Version:

Android API Version:4.4 Android 手机型号&ROM(Phone model & ROM):

Logcat上下文 Logcat context

07-09 16:00:40.855 12571-12571/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.iflytek.xiri, PID: 12571 java.lang.ExceptionInInitializerError at com.qihoo360.replugin.base.IPC.init(IPC.java:60) at com.qihoo360.replugin.RePlugin$App.attachBaseContext(RePlugin.java:964) at com.qihoo360.replugin.RePluginApplication.attachBaseContext(RePluginApplication.java:67) at com.iflytek.base.BaseApplication.attachBaseContext(BaseApplication.java:90) at android.app.Application.attach(Application.java:181) at android.app.Instrumentation.newApplication(Instrumentation.java:991) at android.app.Instrumentation.newApplication(Instrumentation.java:975) at android.app.LoadedApk.makeApplication(LoadedApk.java:511) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4330) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5030) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.qihoo360.replugin.utils.ReflectUtils.getField(ReflectUtils.java:86) at com.qihoo360.replugin.utils.ReflectUtils.readField(ReflectUtils.java:108) at com.qihoo360.replugin.utils.ReflectUtils.readStaticField(ReflectUtils.java:100) at com.qihoo360.replugin.helper.HostConfigHelper.readField(HostConfigHelper.java:171) at com.qihoo360.replugin.helper.HostConfigHelper.(HostConfigHelper.java:83) at com.qihoo360.replugin.base.IPC.init(IPC.java:60)  at com.qihoo360.replugin.RePlugin$App.attachBaseContext(RePlugin.java:964)  at com.qihoo360.replugin.RePluginApplication.attachBaseContext(RePluginApplication.java:67)  at com.iflytek.base.BaseApplication.attachBaseContext(BaseApplication.java:90)  at android.app.Application.attach(Application.java:181)  at android.app.Instrumentation.newApplication(Instrumentation.java:991)  at android.app.Instrumentation.newApplication(Instrumentation.java:975)  at android.app.LoadedApk.makeApplication(LoadedApk.java:511)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4330)  at android.app.ActivityThread.access$1500(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5030)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)  at dalvik.system.NativeStart.main(Native Method) 

Krosxx commented 5 years ago

我的Application继承: App : MApp : RePluginApplication

在App复写attachBaseContext即可:

 override fun attachBaseContext(base: Context?) {
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
            val y = RePluginHostConfig.ACTIVITY_PIT_COUNT_TASK
        }
        super.attachBaseContext(base)
    }