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.
Related
I've created a project and a library separately using Android Studio, each in a separate folder inside some directory.
I tried to add the library as a module to the project, and noticed that instead of just referencing the library like in Eclipse, the library was copied inside the project directory.
That means that if this happened N times for N projects, then I'll have N copies of the library and I'll need to update them all when any update is to be done.
I'm working on v 1.0.2 of Android Studio.
Any one has a better idea to do it?
Three options I know of:
You can specify the path to the external library:
Android studio add external project to build.gradle
Include the compiled jar file from the library in the libs directory of the N apps.
Publish the artifact (the jar from library project) to a gradle repository and then you can add dependencies to that project just like you would for the support library etc.
See http://gradle.org/docs/current/userguide/artifact_management.html
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.
I have a main project, it has some libs (like library-x, library-y, library-z) and a library project. In the library project I import the same libraries with the same versions of the main project (for example library-x and library-y).
When I compile the project, in my application will it duplicate my libraries or adt will take only one library if it is the same project?
Is there any way to use the project's libraries in the library project?
Thank you.
If I understood your question correctly, you can just include your dependencies in the library project and then let the library project export its dependencies. The main project then only includes the library project, but also can access its dependencies.
This can change depending on your development environment, however. With Gradle, for example, you can safely add multiple libraries from Maven and it will automatically remove duplicates.
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've seen lots of libraries in github that has no dependencies for adding them to a project.
The questions are:
How can I use these libraries?
How can I add them to my project?
For instance, this is a gitbub project that I don't know how to use those:
https://github.com/zzhouj/Android-SlidingUpPanel
Normally, you would download a JAR file - if any - or download the project and build the JAR yourself (like you would do for Volley project). But if there is no JAR support, like Android-SlidingUpPanel, just download it and add it as a module in your project.
Try doing this way;
download android-support-v4.jar, add to your LIBS folder,
build project.