I have just updated Eclipse, the Android SDK, and everything else that appeared updatable, via Eclipse's Help->Check for Updates and Window->Android SDK Manager.
My project consists of a main project and 2 library projects. One library project is the normal Android License library project. The other library project contains Java files that reference Android resources that it itself doesn't contain, but that are present in the main project (for example R.id.myPic is used in the library project, but is actually contained in the main project). I had no problem building and running the main project before the update.
For some reason now I cannot build the main project. The main project folder has a "subfolder" called "Library Projects", which contains a jar file for the Android Licensing, but does not show a jar for the second library project. I also have a red exclamation mark on the main project folder.
For some reason I cannot rebuild the library file together with the main project. I've tried Cleaning all projects, building one then the other, building all, restarting Eclipse, but no luck.
If I go to the project properties, then Java Build Path, then Libraries, it appears that the jar file for the library project is missing, but I cannot independently create a jar file for this since it uses resources from the main project.
This is what my problems tab says:
The container 'Library Projects' references non existing library 'C:\AndroidDev\workspace\FlashcardsCommon\bin\flashcardscommon.jar'
Type: Build Path Problem
Any ideas?
Thanks a lot!
See this thread:
http://code.google.com/p/android/issues/detail?id=21031
It generally helps to go to Window -> Preferences -> General ->
Workspace and check "Refresh automatically". Then try clean
building your projects incrementally.
You may also have to remove the source inclusions that represented
your library dependencies manually. You will find that ADT 14 and
15 are very frustrating to work with when you have library projects.
It requires frequent manual cleans of libraries AND their dependent
projects to make changes to library projects effective.
Altogether, good effort by Google, but it's a bit buggy.
Another similar thread:
Cannot build library dependent project after update to ADT 14
Related
I am trying to add android-support-v7-appcompat to my newly created Android project.
Following the Support Library Setup Documentation (developer.android.com/tools/support-library/setup.html), section Adding libraries with resources, I have created an android-support-v7-appcompat project, before adding it as an Android dependency.
EDIT: Here are more details on the process I followed to add the library project as an Android Dependency to the main project:
In the Project Explorer, right-click your project and select Properties.
In the category panel on the left side of the dialog, select Android.
In the Library pane, click the Add button.
Select the library project and click OK.
However, even if the dependency is correctly recognized, Eclipse still sees the compatibility references, such as ActionBarActivity, as errors, forbidding me to build the project. (See picture here).
To solve this problem, I tried the solutions accepted by similar questions on SE, i.e. adding android-support-v7-appcompat to the Project's Build Path, which successfully silents the errors that prevented me to compile earlier.
However, now when building and deploying the project, I get an error: the app crashes at launch, and the Console displays an error message: Could not find android-support-v7-appcompat.apk! (See picture here).
To resume, with the first configuration I am not able to compile with Eclipse, while with the second configuration I can't launch the application.
Therefore, I have two questions:
First, how should I be adding a library to my project, so I can at the same time build my project and be able to use the library's additions in my code in Eclipse?
Secondly, I feel like I am missing theoretical knowledge on how Eclipse handles dependencies.
What is the difference between adding a library as Android dependency vs Java Dependency / vs adding the project or its jar to the Build path?
First, how should I be adding a library to my project, so I can at the same time build my project and be able to use the library's additions in my code in Eclipse?
Your first approach should be fine, which would indicate that there is some other problem. For example, there may be errors in the appcompat library project that are preventing it from being compiled. However, given the error from the second approach, either you are running the appcompat library (which will not work) or something else is more fundamentally broken in your project setup, where your app thinks that it is supposed to build android-support-v7-appcompat.apk, when there is no such APK.
What is the difference between adding a library as Android dependency vs Java Dependency / vs adding the project or its jar to the Build path?
Never manually modify the build path in Eclipse for an Android project. While that will satisfy the compiler, the contents of the JAR(s) will not be packaged into your APK for use at runtime, resulting in runtime crashes (e.g., VerifyError).
"Java dependency" is for pure Java source code. Not only do you not have the source code to appcompat from the SDK, but an Android library project includes Android resources (and, at least on Android Studio, also assets and an optional manifest file).
For Eclipse, library projects are attached via the approach you describe as the first approach in your question. For Eclipse, plain JARs are just dropped into libs/ in your project root, and those are automatically added to your compile-time and runtime classpaths.
I'm trying to get ActionBarSherlock and the ViewPagerIndicator libraries set up for my projects, but I seem to be running into a few issues. I sent Jake Wharton (The developer) a few messages earlier about it, and got a few replies but couldn't get anywhere - and I think he got busy with a few other things.
What my issue is, For both VPI and ABS
Both libraries open up without any errors, and I'm using compiler version 1.6 for all as is required.
The funny thing is, if I load in the samples that are provided - they work fine and link to his library; but when I go to add the library to my project - the above happens.
Where to store the actual library project does not matter, as long as you use a relative link to reference it. Check out the Library Projects - Development considerations:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
You should always use the Eclipse ADT plugin to select and set up Library Project Reference, i.e. right-click project -> Properties -> Android -> Add, then in the opened Project Selection window, select the Library Project list here (of cause you should import them in the same Eclipse workspace as your Main Project). This will add a android.library.reference using relative path into project.properties as well as show relative path in the Android preference window:
android.library.reference.2=../../../../../Documents and Settings/yorkw/Desktop/JakeWharton-Android-ViewPagerIndicator-f09acb0/library
If you directly alter it using absolute path from project.properties as below:
android.library.reference.1=C:\\Documents and Settings\\yorkw\\Desktop\\JakeWharton-Android-ViewPagerIndicator-f09acb0\\library
Then after Eclipse refresh your project, you get the exact error described in your question, see my screenshot below:
Hope this helps.
While importing the libraries, make sure that you tick the "Copy projects int workspace" check box. The library projects need to be in the same workspace for them to work.
delete and import the project and lib again. build the lib project , add lib to project, still error shows.. rename the lib project. this worked for me ....
I have an Android Project(A) that's my main application, it references an Android library Project(B). The Library Project references a standard Java Project(C) which is my standard library for many Java and Android projects. I will reference these three projects as A,B,and C.
My issue is if I make a change to the C project it will auto compile but B doesn't compile hence A doesn't see the changes. The only way to do this is to clean B manually. Is there a way in Eclipse to force B to re-compile when C is compiled?
Using Eclipse 3.6.2 with ADT 14 and SDK 14.
I've also had this problem with ADT 14. In my case, I have less indirection (project A is the PLAIN java library (not an android library), project B is the android app).
What was really fun was that I had two project "B" (two android apps), and one was working. The other was an exact copy (with minor changes for a beta release), including a copy of the project files.
It compiled fine, but failed to package the library files on the beta version.
I removed the project (not deleting the files) and re-added it. Then, I also reconfigured the app's build path and removed the java library. Then I reconfigured it again and re-added it.
Clean/Build and it started packaging them correctly again.
I also did the build order trick mentioned earlier...it didn't help by itself, but may have contributed to the later eclipse refresh working (made sure library project built before others).
I had the exact same issue with ADT 20. Combing the comments with the accepted answer, I found that moving the library project to be the first in Project Properties -> Java Build Path -> Order and Export solved it.
I tried the accepted answer with project B (android) referencing project A (regular java).
After removing and re-adding project B to the workspace, removing project A from project B's required projects, re-adding project B, ticking project B in project A's order/export and moving it to the top and finally clean/build all, my problem was not resolved.
After the clean and build, all was up to date. But when IU changed anything in A, the changes were not visible in B.
My solution:
In the build path of the android project:
- select source tab
- click Link source
- select the java project's src folder. Name it linkedLibrarySource
- apply, clean build
- success
This solution is less than ideal, and I advice to try other solutions first.
There is a disadvantage: eclipse now adds a linkedLibrarySource folder to your android project. It contains the same files as the src folder of your lib. Eclipse sees them as different. This means that you can edit the same file on two locations, causing conflicts. So don't touch linkedLibrarySource!
I use ADT 20
In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed
I have updated my SDK tools to r14. In this link it is told that the library projects will show up as jar files in the projects which uses the library project. But the jar files are not showing up and the <libraryproject>_src folder is still visible. While migrating to r14 from previous version is there any specific step/settings that I need to follow/change so that the library projects are included as jar files? Should I first export the library project as jar file and then include it? I would like to know if anyone has done this and how they have done it?
I got this to work.
I rebuilt the library project and a <libraryproject>.jar appeared in the bin folder. Then I removed the reference from the project which uses the <libraryproject> and added it in the same way as before.
Project properties -> Android -> in the Library section I added the reference to the <libraryproject> and it created a Library Projects in the current project containing the <libraryproject>.jar file.
Fortunately, there was no switch case statements involving the resouce IDs in my entire library projects. For those of you who is not able to get it to work right away, I would suggest them to go through the link I have posted in the Question.