Jar Mismatch Found 2 versions of android-support-v4.jar in the dependency list

前端 未结 14 2083
半阙折子戏
半阙折子戏 2020-11-27 11:32

I am trying to create 2 versions of an Android app (free/paid). I have an Android Library that contains files common to both. I created a new Android project and am trying t

14条回答
  •  Happy的楠姐
    2020-11-27 11:57

    There are some scenarios where you have multiple library projects having the the android-support-v4.jar in their libs and build paths and your project has a dependency towards both of them. Say for example in my case I have the following library projects in my workspace,

    • libfacebook
    • libsherlockactionbar

    Both these projects are independent and my project.properties looks like the following,

    # Project target.
    target=android-17
    android.library.reference.1=../libfacebook
    android.library.reference.2=../libsherlockactionbar
    

    When I build my project, I get a jar mismatch problem having duplicate references to two copies of the same file. What I did to solve this issue is a bit of trickery. I created a new library project named libcommons as a parent to all the other library projects in my workspace, including libfacebook and libsherlockactionbar. Then I removed the support library from all other projects and kept only one copy inside libcommons's libs folder. Then I have added libcommons as a reference to all my other library projects. Once cleaned my workspace, everything works like a charm.

提交回复
热议问题