I finally found the problem myself. The problem was that a layout had the same name in both the Android program project and the apklib project. As a consequence the layout containing the reference to mypackage.R.id in the apkklib project was overridden.
In my case that was the main.xml layout of the library that was overridden by the main.xml layout created by eclipse for the "hello world" project and that I forgot to remove.
Maven was detecting it at compilation time while the Eclipse plugin wasn't, again a bug.
Removing the clandestine "hello world" main.xml from the Android project fixed it.