HighCapable / YukiHookAPI

⛱️ An efficient Hook API and Xposed Module solution built in Kotlin.
https://highcapable.github.io/YukiHookAPI/
Apache License 2.0
1.42k stars 105 forks source link

cannot be cast to 类型转换异常 #61

Closed Xiaolangs closed 10 months ago

Xiaolangs commented 10 months ago

关键代码 context.injectModuleAppResources() ModuleClassLoader.excludeModuleClasses("androidx.appcompat.widget.AppCompatImageView") ModuleClassLoader.excludeHostClasses("androidx.appcompat.widget.AppCompatImageView") val moduleContext = context.applyModuleTheme(androidx.appcompat.R.style.Base_Theme_AppCompat, null) rootView = LayoutInflater.from(moduleContext).inflate(R.layout.test, null) 布局代码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

                <com.xiaolang.wechathelper.widget.BlurView
                    android:id="@+id/blur"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignTop="@id/bottom_bar"
                    android:layout_alignBottom="@id/bottom_bar" />

                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/bottom_bar"
                    android:tag="bottom_bar"
                    app:abb_tabs="@menu/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </RelativeLayout>`

异常 java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageView cannot be cast to androidx.appcompat.widget.AppCompatImageView at com.xiaolang.wechathelper.plugins.Test2BottomBar.getBottomBar(Test2BottomBar.kt:48) at com.xiaolang.wechathelper.plugins.BaseBottomBar.addBottomBar(BaseBottomBar.kt:26) at com.xiaolang.wechathelper.hooker.HomeHooker$onHook$2$1.invoke(HomeHooker.kt:52) at com.xiaolang.wechathelper.hooker.HomeHooker$onHook$2$1.invoke(HomeHooker.kt:46) at com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator$MemberHookCreator$hook$beforeAfterHook$1.afterHookedMember$yukihookapi_core_release( at com.highcapable.yukihookapi.hook.core.api.factory.YukiHookDelegateFactoryKt.callAfterHookedMember(YukiHookDelegateFactory.kt:102) at com.highcapable.yukihookapi.hook.core.api.compat.HookCompatHelper$compat$9.afterHookedMethod(HookCompatHelper.kt:86) at A.BhBfpdEl.eyyOj.qImQN.XposedBridge$LegacyApiSupport.handleAfter(Unknown Source:33) at J.callback(Unknown Source:292) at LSPHooker_.d(Unknown Source:8) at com.tencent.mm.ui.HomeUI.h(Unknown Source:457) at com.tencent.mm.ui.LauncherUI.onResume(Unknown Source:228) at android.app.Instrumentation.callActivityOnResume(Unknown Source:3) at com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.InstrumentationDelegate.callActivityOnResume(InstrumentationDelegate.kt:284) at android.app.Activity.performResume(Unknown Source:68) at android.app.ActivityThread.performResumeActivity(Unknown Source:167) at android.app.ActivityThread.handleResumeActivity(Unknown Source:6) at android.app.servertransaction.ResumeActivityItem.execute(Unknown Source:12) at android.app.servertransaction.ActivityTransactionItem.execute(Unknown Source:4) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(Unknown Source:32) at android.app.servertransaction.TransactionExecutor.execute(Unknown Source:79) at android.app.ActivityThread$H.handleMessage(Unknown Source:172) at android.os.Handler.dispatchMessage(Unknown Source:19) at android.os.Looper.loopOnce(Unknown Source:182) at android.os.Looper.loop(Unknown Source:82) at android.app.ActivityThread.main(Unknown Source:123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11) at com.android.internal.os.ZygoteInit.main(Unknown Source:312)

fankes commented 10 months ago

排除功能目前是实验性的,而且你的用法错误,并且不建议在 xml 里使用 appcompat。

有问题 README 顶部联系方式加群交流吧,issues 这里非严重 bug 或者框架问题不再一条一条回复,解决问题的效率不是很高