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?
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.
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.
Related
My app depends on a library project. This library project depends on the Android Compatibility Package V4. I have NOT exported the library project's dependency. In my own project, I've added ACL V13 as a dependency, but when compiling I get the error that essentially there's a duplicate dependency. I thought not exporting the library project's dependency would resolve this issue, but it's not.
How can I resolve this?
EDIT
Also, according to Android tools docs:
Special case for android-support-v4.jar and android-support-v13.jar.
We make a special case for these two libraries because -v13 contains a
full version of -v4 inside. If both are found, then only -v13 will be
used.
So it should just work...
If you use exactly the same lib jar in different projects (libs project or standard projects), the apk tools get rid automatically of the duplicate ones.
The problem starts when you have two libs with the same name but not at the same revision.
The android-support-v4.jar and android-support-v13.jar files can be from different revision since there always have the same name in different support package release (http://developer.android.com/tools/extras/support-library.html#Notes)
I would check that you use exactly the same revision of the support libs in your main project and in your lib project.
To make sure, copy the two support libraries jars (located in the android-sdk folder) to your projects libs folder.
{android-sdk}/extras/android/support/v4/android-support-v4.jar
AND
{android-sdk}/extras/android/support/v13/android-support-v13.jar
It should get rid of the problem.
Delete the v4 package from the library.
Clean the Projects.
In my case, I had just updated one of the JARs in the libs/ folder to a new version.
All it took to fix it was to run Build -> Rebuild Project, i.e. issue a 'clean' task before the 'assembleDebug' etc.
Well, in my story I had to delete module dependencies which were the same, add it in library, and then add this library to each module as a dependence.
So:
Module a : Depends on android-v4 (and has it in it's lib folder)
Module b : Depends on android-v4 (and has it in it's lib folder)
Add to libraries of project "android-v4" (for ex from 1st module). Delete it in module b lib folder.
Delete in modules a and b dependence of android-v4
Add to each module dependence -> library -> android-v4 (which you created in 2 step)
I'm not sure if it is the right solution but it works.
Have you tried to change the dependency of the library from v4 to v13 and export it?
Sometimes simply removing v4 support library does not work, you also need to rebuild or the project.
I'm trying to use an external jar file in my Android project, I follwed this step for including it:
I put the jar file in libs.
I configured the build path and now I can see the jar file in the Referenced Libraries section of the project.
I use the import to bring the class that I need inside the program.
But I always get NoClassDefFoundError. This jar already works with a classic java program.
Make sure that the jar is being built with the app. In eclipse,
right click on project --> build path --> configure build path.
Make sure the library is checked in the Order and Export tab.
Since Android SDK 17 there is not even necessary to manually add the jar files to buildpath, because they are added automatically, as stated here. Then I would suggest to:
remove the library from buildpath
clean the project
make sure the jar file is located in a folder called libs (not lib) located in the root folder of your project
refresh the project
run the project
The solution found was recompile the library with the version 6 of java and using the jar fail obtained
I have created an Android library where I included some external jars. These jars are seen in "Referenced Libraries" under the library project. When I reference this library in my other project, it is not able to link the jars that had been added to library. It shows errors to the referenced library under the project.
It should have linked the jars which are added in library, rather, it shows an error in the project in which I have added this library. Can anyone help me figure this out?
Exporting jars from library project through the Properties -> Java Build Path -> Order and Export doesn't actually work at the end: Eclipse is able to compile a dependent project, but jars do not appear in the final apk and you get a runtime exception.
If you've got your library project properly included, go to Properties -> Java Build Path -> Order and Export and check all the JARs you wish to include in your main project. This should work, if everything's in the same workspace.
Copy the files to your project location, probably in a lib folder. Then try to add the library.
I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error
01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.
I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.
Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.
I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one
create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.
I would suggest not making the 'lib' folder manually.
Instead:
Right click Project --> Properties --
Select Java Build Path
Make sure Libraries is the tab selected at the top
Click Add External JARs
Then find your JAR...
Basically, the same way you may have added the PhoneGap.jar
The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.
Try changing the name of the folder to libs instead of lib.
have you added required permission in manifest file..
see the below links
http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html
I have made an android project in eclipse. This project has a library project:
the library project (marked with "is library") has included a jar file.
this library project does a lot of stuff with the use of the jar file.
in code everything is fine.
The problem is that the reference to the jar file doesn't exist anymore when it is compiled and installed to my phone.
When i add the jarfile also to my base project. Then the program works.
However, i don't believe that this is the right solution.
So what does i do wrong?
You should add a libs folder to your project
Then, add the jar to the folder and right click on the .jar file and go to Build Path, and select Add To Path or Build To Path. This way the library will be a part of your project. This should help.
The library jar you used in your Android Library Project must be manually added to the dependent application project's build path, not the Android library project build path itself, check out API here