bmelnychuk / AndroidTreeView

AndroidTreeView. TreeView implementation for android
Apache License 2.0
3k stars 621 forks source link

Crash from signed APK #64

Open nserror opened 8 years ago

nserror commented 8 years ago

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.

bmelnychuk commented 8 years ago

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

nserror commented 8 years ago

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?

bmelnychuk commented 8 years ago

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

nserror commented 8 years ago

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

bmelnychuk commented 8 years ago

Thanks!

sanjutagra commented 8 years ago

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....

gmptr5797 commented 5 years ago

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

gmptr5797 commented 5 years ago

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?