简体   繁体   English

如何包含依赖于同一个库的库?

[英]How to include libraries which both depend on the same library?

My project depends on two libraries, one is ActionBarSherlock and the other is the Facebook SDK . 我的项目取决于两个库,一个是ActionBarSherlock ,另一个是Facebook SDK

Both of these library projects depend on the android-support-library . 这两个库项目都依赖于android-support-library

The problem is now, if I include this library in both library projects, I´m getting this build error 现在的问题是,如果我在两个库项目中都包含这个库,我就会遇到这个构建错误

Android Dex: [MyApp] Unable to execute DX
Android Dex: [MyApp] com.android.dex.DexException: Multiple dex files define Landroid/support/v4/view/PagerAdapter;

How can I manage to let both libraries depend on the same library? 如何设法让两个库依赖于同一个库?

This error usually shows up when you have two different versions of the jar file in your app. 当您的应用程序中有两个不同版本的jar文件时,通常会显示此错误。 Just make sure to include the same jar in both your libraries, and the jar will only be included once in the APK. 只需确保在您的两个库中包含相同的jar,并且jar只会在APK中包含一次。

TO overcome this problem solution is you must have same support library in your all library and main project for that you need to select every project and add support lib as bellow 要克服此问题,解决方案是您必须在所有库和主项目中具有相同的支持库,因为您需要选择每个项目并添加支持库,如下所示

Right click project Android tools Add support library 右键单击项目Android工具添加支持库

Repit for all projects done!! 为所有项目完成重新命名!!

include the android support library in the ActionBarSherlock lib, and then include the ActionBarSherlock library in the Facebook library , and finally include the Facebook library into your project. ActionBarSherlock lib中包含android support library ,然后在Facebook库中包含ActionBarSherlock库,最后将Facebook库包含到您的project.

At Last : Clean your project 最后:清理您的项目

1. Right click on the Project Name
2.  Select Build Path -> Configure Build Path
3.   In Java Build Path, go to the tab Order and Export

4.  Unchecked your .jar library

hope so it help you....:) 希望所以它可以帮助你.... :)

Well I had the same problem. 我有同样的问题。 I solved it by doing this- 1- go to the libs directory of your project. 我通过这样做解决了它 - 1-转到项目的libs目录。 There would be android support library's jar file which would be from Google. 将有来自谷歌的android支持库的jar文件。 Delete this jar. 删除这个罐子。 2- Copy the android support library jar from Facebook SDK's lib directory. 2-从Facebook SDK的lib目录中复制android支持库jar。 3- Paste this jar in libs directory in your project(the same place where you have deleted the jar provided by Google in step 1). 3-将此jar粘贴到项目的libs目录中(在步骤1中删除了Google提供的jar的位置)。 4- Now right click on this jar. 4-现在右键单击这个罐子。 Select 'Build path'. 选择“构建路径”。 Select 'Add to build path' 选择“添加到构建路径”

You are done. 你完成了。 Now you have the same JAR file, which is provided packaged in the Facebook SDK at all places. 现在你有了相同的JAR文件,它在所有地方的Facebook SDK中提供。

Note: Copying in the reverse way ie copying the Google provided support jar into Facebook SDK did not work for me. 注意:以相反的方式复制,即将Google提供的支持jar复制到Facebook SDK中对我来说不起作用。 It was not able to get LocalBroadcastManager. 它无法获得LocalBroadcastManager。 I do not know why. 我不知道为什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在我的库中包含/打包外部库 - Include/package external libraries with my library 所有库都需要包含Firebase和Maps? - Firebase and Maps which all libraries need to include? setState()如何取决于调用哪个组件函数? - How to setState() depend on which component func is called? 如何包含图书馆项目 - How to include library projects 当它具有也是 aar 库的依赖项时,如何为 android 库生成 javadoc? - How to generate javadoc for android library when it has dependencies which are also aar libraries? 编译Android库时,Android Studio包含远程库(AAR) - Android Studio include remote libraries when compiling android library (aar) 不依赖于 AndroidX 库的 AndroidX 项目 - AndroidX project that depend on not AndroidX libraries 如何在同一应用程序项目中多次将一个库模块包含到多个库模块中? - How to include a library module multiple times into multiple library modules in the same app project? 如何在一个项目中同时使用 Androidx 库和支持库? - How to use both Androidx libraries and support libraries in one project? 使用不同的库在Android和JVM上执行SAME程序 - Executing SAME program on both Android and JVM using different libraries
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM