OneSignal-Cordova-SDK icon indicating copy to clipboard operation
OneSignal-Cordova-SDK copied to clipboard

BUILD FAILED (Android) Error: ADMMessageHandler must extend

Open ararage opened this issue 3 years ago • 25 comments

Description: Hi, my Ionic/Cordova app can not be build with the last version of the OneSignal plugin. It works with [email protected] (Android 28) but it does not work with [email protected] targeting Android 29, generating the signed APK throws strange errors related with the Amazon SDK and a corrupted APK.

Environment Cordova CLI : 10.0.0 OneSignal: 2.11.0 Android Target: 29 Ionic CLI: 6.11.1 Ionic Framework: @ionic/angular 4.7.4

Steps to Reproduce Issue: 1.- Add the onesignal-cordova-plugin to your project 2.- Build the project ($ ionic cordova build --release android)

Console Output:

cordova build android --release Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=/Users/ararage/Library/Android/sdk (DEPRECATED) Using Android SDK: /Users/ararage/Library/Android/sdk Reading build config file: /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/build.json

BUILD SUCCESSFUL in 1s 1 actionable task: 1 executed Subproject Path: CordovaLib Subproject Path: app Starting a Gradle Daemon, 5 stopped Daemons could not be reused, use --status for details

Configure project :app WARNING: The onesignal-gradle-plugin MUST be before com.android.application! Please put onesignal-gradle-plugin first OR update to com.android.tools.build:gradle:3.0.0 or newer! WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed in version 5.0 of the Android Gradle plugin. For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

Task :app:compileReleaseJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/platforms/android/app/src/main/java/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

Task :app:lintVitalRelease /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/platforms/android/app/src/main/AndroidManifest.xml:13: Error: ADMMessageHandler must extend android.app.Service [Instantiatable] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/platforms/android/app/src/main/AndroidManifest.xml:14: Error: Receiver must extend android.content.BroadcastReceiver [Instantiatable] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

2 errors, 0 warnings

Task :app:stripReleaseDebugSymbols FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:stripReleaseDebugSymbols'. No version of NDK matched the requested version 21.0.6113669. Versions available locally: 21.3.6528147, 21.3.6528147

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 7s 42 actionable tasks: 42 executed Command failed with exit code 1: /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/platforms/android/gradlew cdvBuildRelease -b /Users/ararage/Documents/Projects/xxxxx/2019-2020/xxxxx/platforms/android/build.gradle [ERROR] An error occurred while running subprocess cordova.

    cordova build android --release exited with exit code 1.
    
    Re-running this command with the --verbose flag may provide more information.

ararage avatar Aug 25 '20 00:08 ararage

Same issue here

filippodicostanzo avatar Sep 08 '20 17:09 filippodicostanzo

@ararage did u solve?

filippodicostanzo avatar Sep 08 '20 17:09 filippodicostanzo

I'm getting the same issue

Environment

onesignal-cordova-plugin: v2.11.1 cordova: 10.0.0 cordova-android: 9.0.0

/app/platforms/android/app/src/main/AndroidManifest.xml:27: Error: ADMMessageHandler must extend android.app.Service [Instantiatable]
        <service android:exported="false" android:name="com.onesignal.ADMMessageHandler" />
                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/app/platforms/android/app/src/main/AndroidManifest.xml:28: Error: Receiver must extend android.content.BroadcastReceiver [Instantiatable]
        <receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   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.

mkuklis avatar Sep 12 '20 04:09 mkuklis

I'm getting the same issue

candidoalbertosilva avatar Sep 19 '20 16:09 candidoalbertosilva

Also confirming this issue with the same same environments as above.

I'll keep debugging but it would be great to receive some feedback on this issue, as the deadline for requiring API 29 is fast approaching!

I will add that debug apps build fine, this bug only occurs when building a signed release.

edenist avatar Sep 25 '20 08:09 edenist

@ararage did u solve?

Unfortunately no :(

ararage avatar Sep 26 '20 20:09 ararage

Duplicate of https://github.com/OneSignal/OneSignal-Android-SDK/issues/890

Please follow the issue there.

Once this is fixed on the native side. We will be able to put a release for Cordova.

Cheers

rgomezp avatar Oct 02 '20 23:10 rgomezp

The fix from Issue890 did not resolve the original error: ADMMesssageHandler must extend.

Please assist.

bbl-rpheredia avatar Oct 21 '20 20:10 bbl-rpheredia

@bbl-rpheredia The fix is in OneSignal-Android-SDK 4.0.0-beta2. However this plugin (onesignal-cordova-plugin) does not have a beta version yet using this native beta

jkasten2 avatar Oct 21 '20 21:10 jkasten2

Same issue exact here :)

Rafael-Play-IL avatar Oct 22 '20 07:10 Rafael-Play-IL

Problem is also showing up in my project recently. I'm trying to build the Cordova project, but it is returning this error message

<user>@<computer> android % cordova run android --release -- --keystore=../android-certificates/keystore.jsk --storePassword='<password>' --alias=upload --password='<password>'
Discovered plugin "cordova-plugin-share". Adding it to the project
Plugin "nl.madebymark.share" already installed on android.
Plugin "nl.madebymark.share" already installed on ios.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/Users/<user>/Library/Android/sdk (recommended setting)
ANDROID_HOME=/Users/<user>/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/<user>/Library/Android/sdk
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :app
WARNING: The onesignal-gradle-plugin MUST be before com.android.application!
   Please put onesignal-gradle-plugin first OR update to com.android.tools.build:gradle:3.0.0 or newer!

> Task :app:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/<user>/Git/<project>/src-cordova/platforms/android/app/src/main/java/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :app:lintVitalRelease
/Users/<user>/Git/<project>/src-cordova/platforms/android/app/src/main/AndroidManifest.xml:41: Error: ADMMessageHandler must extend android.app.Service [Instantiatable]
    <service android:exported="false" android:name="com.onesignal.ADMMessageHandler"/>
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/<user>/Git/<project>/src-cordova/platforms/android/app/src/main/AndroidManifest.xml:43: Error: Receiver must extend android.content.BroadcastReceiver [Instantiatable]
    <receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   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.

2 errors, 0 warnings

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 33s
44 actionable tasks: 44 executed

Result of cordova requirements android

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-30,android-29,android-28,android-22
Gradle: installed /usr/local/Cellar/gradle/6.7/bin/gradle

Please help 😅

martijnsmitt avatar Oct 22 '20 12:10 martijnsmitt

Error happening here too, Any news?

jaanguita avatar Nov 04 '20 15:11 jaanguita

Howdy, This will be resolved when the major release for the OneSignal Cordova SDK goes into beta. Thanks for your patience

rgomezp avatar Nov 09 '20 18:11 rgomezp

@rgomezp,

This is good news, thank you. Is there an estimated time of completion?

bbl-rpheredia avatar Nov 09 '20 19:11 bbl-rpheredia

Any news? The problem remains for me.

glehm avatar Dec 07 '20 22:12 glehm

We didn't have errors nor warnings on the installation of "com.onesignal.ADMMessageHandler" service.

But I think this service can access location data from background in some conditions (if the app has the location access permissions in the manifest and the minimum Android version supported is < 8.0 with target SDK 30).

With the new Play Store rules, you have to declare which "sensitive" feature your app uses, in foreground and/or in background. This service causes the detection of a "background location access" and you need to justify it (even with a demo video).

We had to manually remove the service from the manifes, in order to achieve a successful review.

Meow8p avatar Dec 18 '20 07:12 Meow8p

Howdy, Unfortunately this won't be released until some time in the new year. Thanks everyone for your patience. I will leave this one open in this repository for tracking purposes.

@Meow8p Thanks for the details

rgomezp avatar Dec 18 '20 20:12 rgomezp

any update please?

HIMSAI724 avatar Jan 03 '21 15:01 HIMSAI724

No update yet @HIMSAI724 . I have bumped the priority to Medium, however.

Thanks everyone for your patience.

rgomezp avatar Jan 04 '21 22:01 rgomezp

So basically the new major release does not support Amazon yet? Is there an estimation for the fix?

Shani-Rabi avatar Feb 17 '21 12:02 Shani-Rabi

+1

distalx avatar Jun 27 '21 10:06 distalx

Any update?

chaymankala avatar Aug 06 '21 11:08 chaymankala

Since I updated the cordova plugin android to 10.0.0 I also have this problem Is there a solution to this?

99009

orelbutbul avatar Aug 16 '21 13:08 orelbutbul

Hello are folks still experiencing this issue in the 3.0.1 version of the SDK?

emawby avatar Feb 02 '22 17:02 emawby

+1

aishwaryarh avatar Sep 16 '22 06:09 aishwaryarh