I have some project #1 which is library.
E.g. it works with GCM (C2DM) messages and has permissions (my_package.permission.C2D_MESSAGE
and others) inside itself manifest file.
I connect project #1 (lib) to project #2 (some app).
Question: Is it possible to automatically activate permissions from project #1 for project #2 ?
Not presently. If "library" means "Android library project", this may be possible in the future.
However, in your specific case, that will probably never work. Some of the GCM framework classes are going to use the application's package, regardless of whether the code that uses GCM is in an Android library project or not.
I have gotten this to work with AndroidStudio and mainfestmerging. I have all of the GCM permissions, the broadcast receiver and the intent receiver in a library project. The intent service in my library calls an intent service in my app. In my case, the app, registers this service name with the library and it is stored in a database, so the library intent service knows which intent to use for the application. I have no GCM code or permissions anywhere in my application. Here is my Library Manifest
and here is my application manifest
As CommonsWare points out, you have to be careful with your packages. The package for your ComponentName for your intent services (library or app) is always the application package, as the code for my BroadcastReceiver illustrates.
Also, be advised that you can't use the Google BroadcastReceiver; you need to define your own as above. In principle I could have launched the app intent from the broadcast receiver, but since I get the app intent name from a database, it is ill advised to do such operations in a broadcast receiver.
Hope that helps.