I followed some steps I found here (can't find the URL right now, sorry) to convert my Android project in Eclipse to a layout where 99.9% of my code is in a library project, and then I have 2 other shell projects under the same workspace that are mostly just the AndroidManifest.xml files, and a few resource files. This was done so I can support 2 builds of the same project, with just some minor text/icon changes between the 2. The application name is also different so I can publish both on the Android Market at the same time.
Ever since I did this, about every 10 times I compile, maybe once every day or two, I get "dalvik error 1" and something about "Access already exists" (Access being the name of the first Java unit in my library project).
To "work around" the issue I go in to the Java Build path for my stub-project that I am trying to build, and remove the JAR file from my main library from the libraries tab. Then I can build without the error.
Then a while later (maybe 1 or 2 days) I'll get an error about missing classes when I compile my stub-project (not my library). So I'll go back to the Java Build path and put the reference to the JAR file back in, and all is good again for 1 or 2 days, then I'm back to the same error as before.
Is this just a known issue and something I need to do, or can I resolve by a restructure of my projects/workspaces? Currently I have:
Lib Project - only has 2 libs on build path: Android 2.1 and com.android.ide.eclipse.adt.LIBRARIES
First stub project that uses above lib - has the same 2 libs as above project, plus sometimes I use "Add JAR" to include the JAR from the above project's bin\ folder.
2nd stub project - same libs as first stub project
Should I reference the JAR from my "lib project" using one of the other tabs under build path options? Maybe the "Project" tab instead, or the "Source" tab? I don't currently have it under any of those other areas.
When I get in to the weird state, doing a "Clean project" also doesn't help, I've tried that several times and open/close the IDE between cleaning, to no resolve.
At this point we are in the final testing stages, so my normal daily task is:
Make a minor update (bug fix) in the LIB project
Use the publish wizard to export both projects and update Android Market and other places we keep the APK files
So I'd like those steps to stay simple, without having to open/close multiple workspaces or go through a lot of build steps if possible.
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.
Right-click the project and select "Build Path » Add Libraries..." from the pop-up menu. From the dialog window that pops up, select "User Library" and click the "Next" button.
Properties
.Java Build Path
.Libraries
tab.Now, it depends how you compile your library.
So either do an Add JARs...
or an Add Class Folder
.
Choose the external
variant to use an external source.
That's it.
Properties
.Java Build Path
.Projects
tab.Click Add...
on the right side and you are done.
Two steps are necessary:
Right click your project and select Properties
.
Select Android
on the left and tick the checkbox IsLibrary
. Done.
Right click your project and select Properties
.
Select Android
on the left and Add...
your marked project. It will be added to the list and is ready to use. Now you are able to access all classes and ressources (e.g. drawables, strings) from the referenced, marked project. Awesome, eh? :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With