Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: java.lang.reflect.InvocationTargetException #122

Open
fail572872916 opened this issue Nov 3, 2022 · 2 comments
Open

Caused by: java.lang.reflect.InvocationTargetException #122

fail572872916 opened this issue Nov 3, 2022 · 2 comments

Comments

@fail572872916
Copy link

当我在该框架上使用大疆sdk时,我遇到如下问题

 App has crashed, executing CustomActivityOnCrash's UncaughtExceptionHandler
                                                                                                    android.view.InflateException: Binary XML file line #18 in me.hgj.jetpackmvvm.demo:layout/fragment_home: Binary XML file line #18 in me.hgj.jetpackmvvm.demo:layout/fragment_home: Error inflating class dji.ux.widget.FPVOverlayWidget
                                                                                                    Caused by: android.view.InflateException: Binary XML file line #18 in me.hgj.jetpackmvvm.demo:layout/fragment_home: Error inflating class dji.ux.widget.FPVOverlayWidget
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException

这是错误截图
mvvm错误
为了验证我,下载了此项目,将 fragment.xml中加入如下代码
<dji.ux.widget.FPVOverlayWidget android:id="@+id/fpv_overlay_widget" android:layout_width="match_parent" android:layout_height="match_parent" />

微信截图_20221103131446

我增加了以下依赖
微信截图_20221103131504

当我使用以下封装时可以正常使用viewbinding
val aClass = (superclass as ParameterizedType).actualTypeArguments[0] as Class<*> try { val method = aClass.getDeclaredMethod("inflate", LayoutInflater::class.java) binding = method.invoke(null, layoutInflater) as T setContentView(binding!!.root) } catch (e: Exception) { e.printStackTrace() }
我不是很清楚您的封装问题出在哪里

@hegaojian
Copy link
Owner

这个可能是大疆SDK里面的 基础库版本太低了,导致DataBinding反射失败了,如果无法更改可以将当前Activity继承非DataBinding/ViewBinding 的基类,而去继承 BaseVmActivity

@fail572872916
Copy link
Author

我看到1.2.6的反射方式跟我提到的一样,我也回退到1.2.6试了下,结果还是失败,dji在组件里面有混淆操作,我不知道是不是这个原因造成的
aaaaaaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants