我使用的是最新的Android工作室,我正在寻找一种方式来使用支持库,从多个项目。基本上我有一个使用 ActionBarSherlock
这个项目需要支持库的项目。所以我增加了一个referece像在这个问题。
I'm using the new Android Studio, I'm looking for a way to use the support library from multiple projects. Basically I have a project that uses the ActionBarSherlock
this projects requires the support library. So I added a referece as like in this question.
现在我有我的主要项目还采用了支持库,所以我把它包括两次在某些方面的问题。如果我从两个项目之一删除libary我会得到错误,一些支持库相关的类是未知这是明确的我,但如果我有这两个项目的参考,我会面对这样的错误:
Now I have the problem that my main project also uses the support library so I have it includes twice in some way. If I remove the libary from one of both projects I'll get errors that some support library related classes are unknown which is clear for me, but if I have a reference in both projects I'll face this error:
Android Dex: [ProjectName] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Dex: [ProjectName] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ShareCompat$ShareCompatImplJB;
Android Dex: [ProjectName] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
Android Dex: [ProjectName] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
Android Dex: [ProjectName] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
Android Dex: [ProjectName] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
...
不知道如何解决这一问题?
Any idea how to fix this?
推荐答案
我通过进入文件&gt解决了这个问题;项目结构...
并选择模块
然后在模块的依赖
设置页。然后旁边的图书馆我改变范围从编译
到提供
。
I fixed this by going into File > Project Structure...
and selecting Modules
then click on the module's Dependencies
tab. Then next to the library I changed the scope from Compile
to Provided
.
这意味着该模块仍然可以使用它,但它并没有达到编译,因为我假设你已经在使用该JAR在您的主项目。
This means the module can still use it, but it doesn't reach compile, since I assume you are already using that JAR in your main project.
希望这有助于!
相关推荐
最新文章