的InvocationTargetException在膨胀的XML - 机器人机器人、InvocationTargetException、XML

2023-09-12 09:49:54 作者:⊙﹏⊙

我有一个code的工作99%的时间,因为就是部署大量客户端,但有时我得到如下:

I have a code that works 99% of the time since is deploy in lots of clients, but sometimes I get the following:

java.lang.reflect.InvocationTargetException     android.widget.LinearLayout(LinearLayout.java:92)       java.lang.reflect.Constructor.constructNative(本机方法)       java.lang.reflect.Constructor.newInstance(Constructor.java:446)       android.view.LayoutInflater.createView(LayoutInflater.java:499)       com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)       android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)       android.view.LayoutInflater.rInflate(LayoutInflater.java:617)       android.view.LayoutInflater.inflate(LayoutInflater.java:407)       android.view.LayoutInflater.inflate(LayoutInflater.java:320)       com.my code.my code.MyClass.draw(XXXXXXX)   ......

java.lang.reflect.InvocationTargetException android.widget.LinearLayout.(LinearLayout.java:92) java.lang.reflect.Constructor.constructNative(Native Method) java.lang.reflect.Constructor.newInstance(Constructor.java:446) android.view.LayoutInflater.createView(LayoutInflater.java:499) com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562) android.view.LayoutInflater.rInflate(LayoutInflater.java:617) android.view.LayoutInflater.inflate(LayoutInflater.java:407) android.view.LayoutInflater.inflate(LayoutInflater.java:320) com.mycode.mycode.MyClass.draw(xxxxxxx) .....

和我的code,我有:

and on my code I have:

LayoutInflater李=(LayoutInflater)本                       .getSystemService(Context.LAYOUT_INFLATER_SERVICE);               theview = li.inflate(R.layout.partofthescreen,                       somecontainer,假);

LayoutInflater li = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); theview = li.inflate(R.layout.partofthescreen, somecontainer, false);

所以,问题是为什么我收到的InvocationTargetException。

so the question is why I am getting InvocationTargetException.

感谢

推荐答案

您可以尝试 getLayoutInflater(),而不是你的 getSystemService()打电话,虽然我不知道这会有所作为。

You can try getLayoutInflater() instead of your getSystemService() call, though I am not sure that will make a difference.

这是的InvocationTargetException 来自反思,意味着方法被调用抛出了一个异常。你看到的可能是潜在的异常另一个堆栈跟踪任何迹象?如果没有,尝试捕捉的InvocationTargetException 看着的getCause()来看看什么是真正回事。

An InvocationTargetException comes from reflection, and means the Method that was invoked threw an Exception. Do you see any sign of another stack trace that might be the underlying Exception? If not, try catching InvocationTargetException and looking at getCause() to see what is really going on.