This error usually shows up when you have two different versions of the jar file in your app. Just make sure to include the same jar in both your libraries, and the jar will only be included once in the APK.
How to include libraries which both depend on the same library?
-
14-10-2022 - |
Question
My project depends on two libraries, one is ActionBarSherlock
and the other is the Facebook SDK
.
Both of these library projects depend on the 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?
La solution
Autres conseils
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
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.
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. There would be android support library's jar file which would be from Google. Delete this jar. 2- Copy the android support library jar from Facebook SDK's lib directory. 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). 4- Now right click on this jar. 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.
Note: Copying in the reverse way i.e. copying the Google provided support jar into Facebook SDK did not work for me. It was not able to get LocalBroadcastManager. I do not know why.