AndroidTreeView icon indicating copy to clipboard operation
AndroidTreeView copied to clipboard

Crash from signed APK

Open nserror opened this issue 8 years ago • 8 comments

I am experiencing a crash only from a signed APK build, working flawlessly in debug mode.

Crash is happening when I instantiate the tree view.

Here is the crash

03-14 10:38:24.908 28668-28668/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.treeviewapp.treeviewapp, PID: 28668 java.lang.RuntimeException: Could not instantiate class class com.treeviewapp.treeviewapp.b.a at com.unnamed.b.atv.view.AndroidTreeView.getViewHolderForNode(Unknown Source) at com.unnamed.b.atv.view.AndroidTreeView.addNode(Unknown Source) at com.unnamed.b.atv.view.AndroidTreeView.expandNode(Unknown Source) at com.unnamed.b.atv.view.AndroidTreeView.getView(Unknown Source) at com.unnamed.b.atv.view.AndroidTreeView.getView(Unknown Source) at com.treeviewapp.treeviewapp.Fragments.a.h(Unknown Source) at com.treeviewapp.treeviewapp.Fragments.a.d(Unknown Source) at com.treeviewapp.treeviewapp.Fragments.q.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Here is my code to instantiate the tree view.

    `TreeNode root = meeting.rootNode(getActivity());
    rootNode = root;

    tView = new AndroidTreeView(getActivity(), root);
    tView.setDefaultAnimation(true);
    tView.setDefaultViewHolder(AgendaItemHolder.class);
    tView.setDefaultNodeClickListener(nodeClickListener);

    mAgendaHolder.addView(tView.getView());`

Any idea why this could be happening, and only in a signed APK? I am using pro guard and I tried adding a rule to exclude the TreeView ( -keep class com.unnamed.b.atv.** { *; } ). This helped the code get about 5 lines further. Seems to be failing now when I call getView() to add it to my layout.

nserror avatar Mar 14 '16 14:03 nserror

Did you enable proguard in your app? I think that is the reason

bmelnychuk avatar Mar 14 '16 14:03 bmelnychuk

It is enabled. It is a must for my app. I am using -keep class com.unnamed.b.atv.** { *; } in my pro guard rules to exclude the tree view. Is there any further steps I could take?

nserror avatar Mar 14 '16 14:03 nserror

Unfortunately I am not that advance in proguard. Need to check and try it

bmelnychuk avatar Mar 14 '16 14:03 bmelnychuk

I found this on stack overflow which solved my issue. In your pro guard rules you must keep all classes in your project that are subclasses of TreeNode. Please consider adding this information to the Read Me to help others with pro guard enabled in the future!

http://stackoverflow.com/questions/30480816/android-treeview-lib-and-proguard-encounter

nserror avatar Mar 16 '16 14:03 nserror

Thanks!

bmelnychuk avatar Mar 16 '16 14:03 bmelnychuk

I don't think this has something to do with proguard. Your rules look fine. I am having a similar crash with same stack trace and the reason is "The specified child already has a parent. You must call removeView() on the child's parent first." I don't know whether you have the same issue or not but it can be....

sanjutagra avatar Jul 07 '16 05:07 sanjutagra

Has anyone got the resolution for this error? I am facing the same problem in my app after using the pro guard.

gmptr5797 avatar Jul 12 '19 05:07 gmptr5797

I found this on stack overflow which solved my issue. In your pro guard rules you must keep all classes in your project that are subclasses of TreeNode. Please consider adding this information to the Read Me to help others with pro guard enabled in the future!

http://stackoverflow.com/questions/30480816/android-treeview-lib-and-proguard-encounter

Has this solution resolved your problem?

gmptr5797 avatar Jul 12 '19 05:07 gmptr5797