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

0

6

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?

Note: In the sample code of Amazon device messaging, it also did the same.

Update 1

I've also asked here, and received the answer:

If you are following this 1 documentation then you should be fine. The error you see should just be a warning and can be ignored. The declaration in AndroidManifest.xml is a must.

Cards answered 14/10, 2020 at 6:14 Comment(3)
I'm surprised that no one has answered this question. It's a legitimate issue with ADMMessageHandlerJobBaseYoko
I am having the same issue and my ADMMessageJobBase callbacks are not triggering. Can anyone help ?Graf
@Graf did you find a solution for the callbacks not triggering?Pedicular

© 2022 - 2024 — McMap. All rights reserved.