2 z dong dong Z_dong_dong 于 2015.06.09 15:44 提问

安卓类型转换异常,求大神指导,真心做不出来

公司的外包项目,客户那边经常报这个错误,我都不知道怎么去查这个错误,不知道问题出在哪里,什么情况下回出现这个问题,怎么去解决这个问题,求大神或者遇到过此问题的朋友帮帮忙,耐心解决一下,求!!! 谢谢。

java.lang.ClassCastException: android.widget.RelativeLayout$DependencyGraph$Node cannot be cast to java.lang.Object[]
at android.util.ArrayMap.allocArrays(ArrayMap.java:185)
at android.util.ArrayMap.put(ArrayMap.java:444)
at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1738)
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1667)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:373)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:381)
at android.view.View.measure(View.java:16602)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5161)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16602)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5161)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16602)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5161)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2374)
at android.view.View.measure(View.java:16602)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1938)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1135)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1317)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1022)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5860)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5140)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)

6个回答

u011133213
u011133213   2015.06.09 18:22

你的另一个问题李我已经给你回复了:
setMesseage(resourceId, new String[]{你的string变量})
类型转换失败就是找到那个错误的参数类型就行了!

xby1993
xby1993   2015.06.10 00:35

光贴个异常栈,关键代码不贴出来,怎么分析啊?

Z_dong_dong
Z_dong_dong 主要是我不知道它出在哪里,也不知道什么时候出的异常,是友盟反馈的
2 年多之前 回复
xby1993
xby1993   2015.06.10 11:33

android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1738):
private ArrayDeque findRoots(int[] rulesFilter) {
final SparseArray keyNodes = mKeyNodes;
final ArrayList nodes = mNodes;
final int count = nodes.size();

        // Find roots can be invoked several times, so make sure to clear
        // all dependents and dependencies before running the algorithm
        for (int i = 0; i < count; i++) {
            final Node node = nodes.get(i);
            node.dependents.clear();
            node.dependencies.clear();
        }

        // Builds up the dependents and dependencies for each node of the graph
        for (int i = 0; i < count; i++) {
            final Node node = nodes.get(i);

            final LayoutParams layoutParams = (LayoutParams) node.view.getLayoutParams();
            final int[] rules = layoutParams.mRules;
            final int rulesCount = rulesFilter.length;

            // Look only the the rules passed in parameter, this way we build only the
            // dependencies for a specific set of rules
            for (int j = 0; j < rulesCount; j++) {
                final int rule = rules[rulesFilter[j]];
                if (rule > 0) {
                    // The node this node depends on
                    final Node dependency = keyNodes.get(rule);
                    // Skip unknowns and self dependencies
                    if (dependency == null || dependency == node) {
                        continue;
                    }
                    // Add the current node as a dependent
                    dependency.dependents.put(node, this);
                    // Add a dependency to the current node
                    node.dependencies.put(rule, dependency);
                }
            }
        }

        final ArrayDeque<Node> roots = mRoots;
        roots.clear();

        // Finds all the roots in the graph: all nodes with no dependencies
        for (int i = 0; i < count; i++) {
            final Node node = nodes.get(i);
            if (node.dependencies.size() == 0) roots.addLast(node);
        }

        return roots;
    }

            估计是你的xml布局参数除了问题
chengxuyuanit
chengxuyuanit   2016.11.14 11:05

楼主有解决了么?现在知道原因了么?

yulong0809
yulong0809   2016.12.17 12:11

请问解决了吗,碰到的同样的问题,如解决了,请分享下,感谢楼主

dkmeteor
dkmeteor   2017.03.14 09:56

一个系统bug,,目前没有有效的解决方案

Issue 218944: ClassCastException in SimpleArrayMap.allocArrays()
https://code.google.com/p/android/issues/detail?id=218944

Csdn user default icon
上传中...
上传图片
插入图片