After failing to use an Android project as library (see this if you want details) I exported the project's JAR file and (created and) added to the 'libs' folder. I also added the JAR file to the Project's build path.
But I got this runtime error:
04-09 00:40:40.209: E/AndroidRuntime(20499): FATAL EXCEPTION: main
04-09 00:40:40.209: E/AndroidRuntime(20499): java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.example.android.tictactoe/com.example.android.tictactoe.library.GameActivity}:
java.lang.ClassCastException: android.widget.Button cannot be cast
to com.example.android.tictactoe.library.GameView
After a quick check it turns out that the JAR library I brought to libs has defined resources ID's that are the same as resources ID's in the main project. And as a consequence a Button (in TicTacToeMain) and GameView (in TicTactToeLib) got the same ID number.
Solutions, anyone?
The only solution I found is to get the library to work as an Android Project Library (marked as is library
in the project's properties)
Once you add the Library project to the target project (again through the project's properties) and Apply it, the R class of the library get renumbered and added to the target project.
This being said, it took me some time to make the Referenced Library project to be accepted, while using Eclipse. After several (many) tries and total deletes and re-create of the library project, the library reference was "accepted" when I pressed Apply and it all worked perfectly.
If you want to read more details about my ordeal getting the library to be "accepted", read it all in this post.