question

Adam Pehas avatar image
Adam Pehas asked

Build error when using Amazon Device Messaging: class must extend android.app.Service [Instantiatable]

We are running into the same issue as the below post any support is welcome:

https://stackoverflow.com/questions/64347595/build-error-when-using-amazon-device-messaging-class-must-extend-android-app-se


I'm integrating Amazon device messaging into my app following this Offical docs. According to the docs, I have to create a class (MyADMMessageHandler.java) that extends ADMMessageHandlerJobBase and declare my class as a Service in AndroidManifest.xml

AndroidManifest.xml

<service android:name=".pn.MyADMMessageHandler"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE"/>

But when I built my app, I got this error

AndroidManifest.xml:153: Error: MyADMMessageHandler must extend android.app.Service [Instantiatable]
  <service android:name=".pn.MyADMMessageHandler"                           

   Explanation for issues of type "Instantiatable":
   Activities, services, broadcast receivers etc. registered in the manifest
   file (or for custom views, in a layout file) must be "instantiatable" by
   the system, which means that the class must be public, it must have an
   empty public constructor, and if it's an inner class, it must be a static
   inner class.

1 errors, 0 warnings

BUILD SUCCESSFUL in 18s

Despite of this error, I still had BUILD SUCCESSFUL. I decompiled amazon-device-messaging-1.1.0.jar to see what's going on, but it just contains stub implementation and ADMMessageHandlerJobBase doesn't extends Service or any subclass of Service.

So MyADMMessageHandler class isn't a Service but why do we need to declare it as a Service in AndroidManifest.xml?

fire tvamazon device messagingandroid
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi Adam,

Thanks for posting. If I understood correctly, your project builds, but you are curious about the error and the reason for requiring implementation of a service? The ADM team is looking into this. Please also note that recently we released an A3L SDK, which is useful in case you are integrating both Firebase Cloud Messaging (FCM) and Amazon Device Messaging (ADM) in your project: https://developer.amazon.com/docs/a3l-messaging/understanding-a3l-messaging.html

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.