Qihoo360 / RePlugin

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

无法启动插件中的activity(ClassCastException) #699

Open yanhaoZ opened 6 years ago

yanhaoZ commented 6 years ago

问题详细描述 Detailed description of the problem

Unable to start activity ComponentInfo{com.test.home/com.test.home.loader.a.ActivityN1NRNTS5}: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout

复现问题步骤 Steps to reproduce the problem

  1. 宿主、插件都按照wiki步骤集成replugin
  2. 宿主与插件都具有com.android.support:appcompat-v7:28.0.0 3、空的host也具备以上条件,可以启动插件。

其它重要信息 Other important information

replugin-host-lib/gradle Version:2.3.0 rePlugin-plugin-lib/gradle Version:2.3.0

Android API Version:8.0.0(26) Android 手机型号&ROM(Phone model & ROM): 小米5(MIUI10.0.1.0)

Logcat上下文 Logcat context

1、插件放到空的host工程中能正常打开 2、主工程的host集成了很多第三方sdk(rxjava、okhttp3、retrofit2等) 3、所有手机,使用主工程的host,都无法启动插件的activity。

10-31 09:46:50.372 1434-2083/? E/ActivityTrigger: activityStartTrigger: not whiteListedcom.test.home/com.test.home.loader.a.ActivityN1NRNTS5/1 10-31 09:46:50.374 1434-2083/? E/ActivityTrigger: activityResumeTrigger: not whiteListedcom.test.home/com.test.home.loader.a.ActivityN1NRNTS5/1 10-31 09:46:50.443 1434-2083/? E/ActivityTrigger: activityResumeTrigger: not whiteListedcom.test.home/com.test.home.loader.a.ActivityN1NRNTS5/1 10-31 09:46:50.579 27071-27071/com.test.home E/AndroidRuntime: FATAL EXCEPTION: main Process: com.test.home, PID: 27071 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.home/com.test.home.loader.a.ActivityN1NRNTS5}: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2854) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2929) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1618) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6696) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) Caused by: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout at android.support.v7.widget.ActionBarOverlayLayout.pullChildren(ActionBarOverlayLayout.java:537) at android.support.v7.widget.ActionBarOverlayLayout.setWindowCallback(ActionBarOverlayLayout.java:615) at android.support.v7.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:611) at android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.hemutest.yh.uitest.Main2Activity.onCreate(Main2Activity.java:48) at android.app.Activity.performCreate(Activity.java:7040) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2807) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2929)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1618)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6696)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) 

hyongbai commented 6 years ago

是否在RePluginConfig中通过setUseHostClassIfNotFound设置了插件宿主共享Class?

如果开启的话,关闭试试。

lili-z commented 4 years ago

兄弟我也是跟你一样的问题,请问你解决了吗,搞不定啊