android R.java and final modifier

I am writing an application, which consists of base module and a number of derived modules. They are only different in package name and resources. Both base and derived modules are application modules. The problem is when the base module is not marked as library, the following happens:
- resources from base are missing in derived app .apk
- if comment out references to resources, derived app crashes at start with ClassNotFoundException(my Activity class).
But if mark base as library then everything is ok.
Is this the intended behaviour? Base dependency scope is set to compile, shouldn't library and not library behave the same way?

PS It is not so important for me to be able to run base app, although it is useful. The more important thing is that i need id's contained in R.java to be final, and for libraries they are not.
If I could optionally mark a module so that R.java is generated with final modifier, or if the base application module resources/classes were included in derived module, that would solve the issue.

changed title

5 comments

Yes the maven feature is expected to be added in the upcoming versions.


_______________
agile testing

0

Hello,

No, library and not library shouldn't behave the same way, because otherwise there is no sense in such setting. The problem is that it is impossible to make R modifiers final in library module, because in such case they are inlined during the compilation of library. The inlined values are obviously wrong, because they are taken from lib's R containing only library resources, but actual IDs of these resources in app are located in the app's R. App->app compile dependency is not actually supported. Currently it behaves as "Provided" and you get warning that "... possibly you should change scope to 'provided'" during compilation

0

Thanks for replying.

But how then did it work earlier? According to http://tools.android.com/tips/non-constant-fields the problem was in the performance.
And will app->app compile dependency ever be supported?

0

Long time ago we did compile java sources of library several times (for every app module using it). It was too slow for projects containing several app modules dependening on the same lib. Actually what is the motivation? Why do you need R fields to be final?

0

I'm using roboguice for the app I'm working on. Roboguice uses annotations, which take view id as a param. I realize that I can specify tag instead, but in the last app I used tags for the different purpose, now it could cause problems. I am also worried about the possible performance loss for using tags.

0

Please sign in to leave a comment.