罐不匹配!修复你的依赖 [英] Jar mismatch! Fix your dependencies

查看:97
本文介绍了罐不匹配!修复你的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重现步骤:




  1. 创建一个Android项目MyApp

  2. import ActionBarSherlock ABS),Directional ViewPager(DVP)或使用Android支持库的任何其他开源库。

  3. 将库添加到项目MyApp



控制台日志:



  [2013-04-17 14:27 :12  -  MyApp]在依赖列表中找到2个版本的android-support-v4.jar,
[2013-04-17 14:27:12 - MyApp],但并不是所有的版本是一样的(检查是否基于在SHA-1上)
[2013-04-17 14:27:12 - MyApp]此时所有版本的库必须相同。
[2013-04-17 14:27:12 - MyApp]找到的版本是:
[2013-04-17 14:27:12 - MyApp]路径:C:\Users\santhosh \My_Workspace\DVP_library\libs\android-support-v4.jar
[2013-04-17 14:27:12 - MyApp]长度:140011
[2013-04-17 14 :27:12 - MyApp] SHA-1:fc834ac8147bc4ed0b555f90f500a57d4232c448
[2013-04-17 14:27:12 - MyApp]路径:C:\Users\santhosh\My_Workspace\abs_library\libs\\ \\ Android-support-v4.jar
[2013-04-17 14:27:12 - MyApp]长度:271754
[2013-04-17 14:27:12 - MyApp] SHA-1 :53307dc2bd2b69fd5533458ee11885f55807de4b
[2013-04-17 14:27:12 - MyApp]瓶子不匹配!修复你的依赖

我知道我想删除android-support-v4.jar从libs文件夹,并保留所有的一个副本。
但是,这不是解决我的问题。



当我尝试从 MyApp中删除android-support-v4.jar ,它给我以下错误。

 删除资源时遇到问题。 
无法删除'C:\Users\santhosh\My_Workspace\MyApp\libs\android-support-v4.jar'。

当尝试从 ABS ,它给我以下错误

 无法解析为类型错误。 

我已经尝试清理项目,修复项目属性。重新启动eclipse,构建,导入并重新添加。我已经尝试将libs文件夹中的支持jar从一个库复制到另一个库。删除两个库中的支持jar并将其添加到MyApp项目中。没有什么对我有用



如果我尝试添加单个库,它可以正常工作。当我尝试在一个项目中添加2个或更多的库时,我正面临这个问题。



在MyApp中添加两个库时出错:

 该项目由于其构建路径不完整而未构建。 
找不到android.support.v4.app.FragmentActivity的类文件。
修复构建路径,然后尝试构建此项目MyApp未知Java问题
无法解析类型android.support.v4.app.FragmentActivity。它是间接引用的所需的.class文件MyActivity.java/MyApp/src/com/santhosh/myapp行10 Java问题
Jar不匹配!修复您的依赖关系MyApp未知Android依赖问题


解决方案

项目仅用于支持库



ADT 22 开始,使用Eclipse Juno



我不认为上述任何一个都是最好的答案。我也不认为建议在Eclipse中使用外部jar 函数(AFAIK)。



相反,对我来说有用的是创建一个单独的空库项目。



然后使用 Android工具> 添加支持库以获取您需要或想要的最新版本。



然后从所有其他项目中删除支持lib jar



最后,对于需要它的每个项目,添加对您的新图书馆项目的引用



(项目属性)> Android > (库框)> 添加... p>

然后,所有的项目都将有一个来源来使用和更新支持库。有关如何设置javadoc的信息,请参阅:





a href =https://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder>如何将javadoc或源添加到libs文件夹中的jar ?


Steps to reproduce:

  1. create a android project "MyApp"
  2. import ActionBarSherlock(ABS),Directional ViewPager(DVP), or any other open source library which use android support library.
  3. Add the libraries to the project "MyApp"

Console log:

[2013-04-17 14:27:12 - MyApp] Found 2 versions of android-support-v4.jar in the dependency list,
[2013-04-17 14:27:12 - MyApp] but not all the versions are identical (check is based on SHA-1 only at this time).
[2013-04-17 14:27:12 - MyApp] All versions of the libraries must be the same at this time.
[2013-04-17 14:27:12 - MyApp] Versions found are:
[2013-04-17 14:27:12 - MyApp] Path: C:\Users\santhosh\My_Workspace\DVP_library\libs\android-support-v4.jar
[2013-04-17 14:27:12 - MyApp]   Length: 140011
[2013-04-17 14:27:12 - MyApp]   SHA-1: fc834ac8147bc4ed0b555f90f500a57d4232c448
[2013-04-17 14:27:12 - MyApp] Path: C:\Users\santhosh\My_Workspace\abs_library\libs\android-support-v4.jar
[2013-04-17 14:27:12 - MyApp]   Length: 271754
[2013-04-17 14:27:12 - MyApp]   SHA-1: 53307dc2bd2b69fd5533458ee11885f55807de4b
[2013-04-17 14:27:12 - MyApp] Jar mismatch! Fix your dependencies

I know i am suppose to delete android-support-v4.jar from libs folder and keep only one copy for all. But, that is not solving my problem.

When i try to delete the android-support-v4.jar from MyApp, it gives me the following error.

 Problems encountered while deleting resources.
 Could not delete 'C:\Users\santhosh\My_Workspace\MyApp\libs\android-support-v4.jar'.

When I try to delete the android-support-v4.jar from ABS, it gives me the following error

 ????? cannot be resolved to a type error.

I have tried to clean the project, Fix Project Properties. Restart eclipse, Build, import and add again. I have tried to copy the support jar in libs folder from one library to other. delete the support jar in both libraries and add it to the MyApp project. Nothing has worked for me.

if i try to add single library, it works fine. i am facing the problem when trying to add 2 or more libraries to a single project.

error getting when I add two libraries in MyApp:

The project was not built since its build path is incomplete. 
Cannot find the class file for android.support.v4.app.FragmentActivity. 
Fix the build path then try building this project MyApp Unknown Java Problem
The type android.support.v4.app.FragmentActivity cannot be resolved. It is indirectly referenced from required .class files MyActivity.java/MyApp/src/com/santhosh/myapp    line 10 Java Problem
Jar mismatch! Fix your dependencies MyApp Unknown Android Dependency Problem

解决方案

Use a Library Project just for the Support Library

As of ADT 22, using Eclipse Juno

I don't think any of the above are really the best answers. I also don't think it is recommended to use the external jar function in Eclipse anymore (AFAIK).

Rather, what worked for me is to create a separate empty library project.

Then use Android tools > Add Support Library to get the latest version you need or want.

Then remove the support lib jar from all other projects.

Finally, for every project that requires it, add a reference to your new Library project

(project properties) > Android > (Library box) > Add...

Then all your projects will have a single source to use and update the support library. This also makes javadocs easier to get working.

For info on how to setup the javadocs see:

How to attach javadoc or sources to jars in libs folder?

这篇关于罐不匹配!修复你的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆