0

I have added 2 libraries into my project using gradle. on run time I get a class name conflict which causes an exception on a type cast line. it seems some classes of these libraries have same name and in one of those casting is used by only class name and not the complete package name.

is there a way to handle class name conflicts?

Update:

this is the exact exception:

FATAL EXCEPTION: main
    Process: com.payamgostar.formmaker, PID: 29589
    java.lang.ClassCastException: com.wdullaer.materialdatetimepicker.date.AccessibleDateAnimator cannot be cast to com.mohamadamin.persianmaterialdatetimepicker.date.AccessibleDateAnimator
        at com.mohamadamin.persianmaterialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:255)
        at android.app.Fragment.performCreateView(Fragment.java:2053)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
        at android.app.BackStackRecord.run(BackStackRecord.java:834)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
        at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
        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)
Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155
Mohammad Rafigh
  • 757
  • 9
  • 17
  • You could use the classes with their package names. – user2520215 Apr 04 '16 at 21:40
  • yes I use like this. it's not the problem, the problem is with the code inside one of those libraries, not mine. I mean casting is happening inside those libraries. – Mohammad Rafigh Apr 04 '16 at 21:41
  • can you post the exact error? – Logain Apr 04 '16 at 21:45
  • if librairy is the same from different version, you could exclude one or the other from the build. Generaly this kind of runtimes errors comes from using same lib & different versions at runtime. – jeorfevre Apr 04 '16 at 21:48
  • yes not different versions but one of those is a fork of the other one (I need both in my case because their functionalities are different). I added the exception – Mohammad Rafigh Apr 04 '16 at 21:55
  • Are they aar or jar dependencies? For jar you could download one of them yourself and use jarjar to change package name. See this issue http://stackoverflow.com/questions/13746737/hand-edit-a-jar-to-change-package-names – Remco Apr 05 '16 at 05:22
  • looks like the resources provided by the libraries are the issue. You can't get around that, as there is no namespace for resources. – njzk2 Apr 05 '16 at 13:07

0 Answers0