Class Extending FirebaseMessagingService not working inside Android Library
<p>I created an Android Library to implement FCM to use in my internal projects, where I implement a class to extend FirebaseMessagingService (<code>.services.MyFirebaseMessagingService</code> ) and another one to extend FirebaseInstanceIdService (<code>.services.MyFirebaseInstanceIDService</code>).</p>

<p>I defined this in my AndroidManifest.xml inside the library as below:
</p>

<pre><code>&lt;!-- [START firebase_service] --&gt;
&lt;service
    android:name=".services.MyFirebaseMessagingService"
    android:exported="true"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
    &lt;/intent-filter&gt;
&lt;/service&gt;
&lt;!-- [END firebase_service] --&gt;
&lt;!-- [START firebase_iid_service] --&gt;
&lt;service android:name=".services.MyFirebaseInstanceIDService"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT" /&gt;
    &lt;/intent-filter&gt;
&lt;/service&gt;
&lt;!-- [END firebase_iid_service] --&gt;
</code></pre>

<p></p>

<p>When I included all the library source code as a module in my App, everything worked well, but when I included only the AAR generated, I received this error when I run my application:</p>

<pre><code>java.lang.RuntimeException: Unable to instantiate service com.example.lib.services.MyFirebaseMessagingService: java.lang.ClassNotFoundException: com.example.lib.services.MyFirebaseMessagingService
  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2380)
  at android.app.ActivityThread.access$1600(ActivityThread.java:138) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4905)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
  at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.example.lib.services.MyFirebaseMessagingService
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2377)
  at android.app.ActivityThread.access$1600(ActivityThread.java:138) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286) 
  at android.os.Handler.dispatchMessage(Handler.java:99) 
  at android.os.Looper.loop(Looper.java:137) 
  at android.app.ActivityThread.main(ActivityThread.java:4905) 
  at java.lang.reflect.Method.invokeNative(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:511) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 
  at dalvik.system.NativeStart.main(Native Method) 
</code></pre>

<p>The service com.example.lib.services.MyFirebaseInstanceIDService works correctly.</p>

<p>What I need to do with AAR generated library to work?</p>