android-support-v7-appcombat jar mismatch and app

2019-04-09 12:44发布

I have been successfully using android-support-v7-appcompat library for last few months in my app to support action bar in older devices. Recently I have downloaded the Android 4.4(kitkat) updates with system image and SDK platform from the SDK Manager. I also added targetSdkVersion to "19" in manifest file. But my project was showing error as 'android-support-v7-appcompat jar mismatch. Fix your dependaecies.' Then I added the jar from /extras/android/support/.... to the project as an external jar using build path menu > add external jar. Now there is no error in the project and android-support-v7-appcompat.jar & android-support0v4.jar file is showing twice under 'Referenced Libraries' folder and also once under 'libs' folder. The project is not showing error and running, but crashing in different activities.

Previously I imported the android-support-v7-appcombat library as an external project in the workplace. I can see error in that project. Please suggest what should I do now. Also, android-support-v7-appcompat.jar umder Android Dependencies in Java Build Path showing error.

The error I see is:

Found 2 versions of android-support-v7-appcompat.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.

Versions found are:

Path: C:\<project hierarchy>\libs\android-support-v7-appcompat.jar

Path: C:\Users\....\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar

 Jar mismatch! Fix your dependencies

After getting idea from different forum, I removed all the android-support-v7-appcompat libraries from different places, and imported android-v7 support library again in the project. Still it's showing error. Should I also delete android-support-v4 libraries from buildpath and libs/private librariry/referenced library folders?

4条回答
成全新的幸福
2楼-- · 2019-04-09 13:17

I have actually figured out the solution by trying different options suggested from different forum. I had manually change the android-support-v7-appcompat project's(which was added as an external project) project.properties file and had to set 'target=android-19'.

查看更多
手持菜刀,她持情操
3楼-- · 2019-04-09 13:28

I had exactly the same problem after installing all the updates mentioned in the question. I am sure there are different ways to solve this problem. Here is the way I used:

Previously, when an activity was created, the following project was automatically generated by the wizard:

androi-support-v7-appcompat and this project was added to the build path.

After all the updates, the following equivalent is generated when an activity is created:

appcompat_v7 with the jars of the same names. I deleted androi-support-v7-appcompat and made sure the projects use appcompat_v7 to replace androi-support-v7-appcompat in their build paths. This made hundreds of errors generated by the duplicates go away.

查看更多
beautiful°
4楼-- · 2019-04-09 13:30

I am glad that i finally found the answer. I was encountering the same problem again and again and i was like fed up.

Here is the answer to your question.

whenever you get such an error just don't touch anything other than libs folder. Just go directly into the libs folder and right away delete the android-support-v4.jar. and clean build your project. You will be relieved to get rid of errors.

Hope its useful to you. Keep coding..

查看更多
等我变得足够好
5楼-- · 2019-04-09 13:36

This error occurs when there are multiple and different instances of the same library are found in the same project, or libraries used by it. A very simple way to resolve this is use the common lib at both the places. To do so:

Just copy your C:\Users....\AppData\Local\Android\android-studio\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar and paste it in your libs folder, replace the old one with this. Clean the project, and it shall compile now..

Edit 1: Basically the idea is if you are using the same libraries, it shall be the common jar, or the same jar. In your case if you are using the appv7 as an external project, please go to libs folder of your project copy android-support-v4.jar, and paste into the libs of android-support-v7-appcompat project.

Also, make sure if there are other external jars or support libraries used by you, they shall be the similar jars in all the projects you are using.

I hope it helps!

查看更多
登录 后发表回答