Cordova-plugin-local-notifications: [0.9.0-beta.3] "NotificationCompat does not exist" cause ionic build error

Created on 8 Nov 2018  路  7Comments  路  Source: katzer/cordova-plugin-local-notifications

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

I am using the "cordova-plugin-local-notification" 0.9.0-beta.2, in an ionic 4 project as per the instruction of native api.

afte the integration , I built the project by command

ionic cordova run android --verbose

the build (after about 40 minutes )failed with the following prompt

... 
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:32: error: package android.support.v4.media.app.NotificationCompat does not exist
import android.support.v4.media.app.NotificationCompat.MediaStyle;
                                                      ^
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:130: error: cannot find symbol
                .setChannelId(options.getChannel())
                ^
  symbol:   method setChannelId(String)
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:296: error: cannot find symbol
        MediaStyle style;
        ^
  symbol:   class MediaStyle
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:298: error: cannot find symbol
        style = new MediaStyle(builder)
                    ^
  symbol:   class MediaStyle
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:417: error: constructor Builder in class Builder cannot be applied to given types;
            builder = new NotificationCompat.Builder(context, options.getChannel());
                      ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

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

BUILD FAILED in 43m 44s
27 actionable tasks: 1 executed, 26 up-to-date
Command finished with error code 1: /home/wjz/ion/arhat/platforms/android/gradlew cdvBuildDebug,-b,/home/wjz/ion/arhat/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
(node:22449) UnhandledPromiseRejectionWarning: Error: /home/wjz/ion/arhat/platforms/android/gradlew: Command failed with exit code 1 Error output:
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:32: error: package android.support.v4.media.app.NotificationCompat does not exist
import android.support.v4.media.app.NotificationCompat.MediaStyle;
                                                      ^
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:130: error: cannot find symbol
                .setChannelId(options.getChannel())
                ^
  symbol:   method setChannelId(String)
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:296: error: cannot find symbol
        MediaStyle style;
        ^
  symbol:   class MediaStyle
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:298: error: cannot find symbol
        style = new MediaStyle(builder)
                    ^
  symbol:   class MediaStyle
  location: class Builder
/home/wjz/ion/arhat/platforms/android/app/src/main/java/de/appplant/cordova/plugin/notification/Builder.java:417: error: constructor Builder in class Builder cannot be applied to given types;
            builder = new NotificationCompat.Builder(context, options.getChannel());
                      ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

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

BUILD FAILED in 43m 44s
    at ChildProcess.whenDone (/home/wjz/ion/arhat/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
(node:22449) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:22449) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Your Environment

print-out of "ionic info"

wjz@bj:~/ion/arhat$ ionic info 

Ionic:

   ionic (Ionic CLI)             : 4.3.1 (/home/wjz/.nvm/versions/node/v10.7.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.15
   @angular-devkit/build-angular : 0.8.6
   @angular-devkit/schematics    : 0.8.6
   @angular/cli                  : 6.2.6
   @ionic/angular-toolkit        : 1.0.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-webview 2.0.2, (and 12 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/wjz/Android/Sdk)
   NodeJS            : v10.7.0 (/home/wjz/.nvm/versions/node/v10.7.0/bin/node)
   npm               : 6.2.0
   OS                : Linux 4.15

Environment:

   HTTP_PROXY  : http://127.0.0.1:37245/
   http_proxy  : http://127.0.0.1:37245/
   HTTPS_PROXY : http://127.0.0.1:37245/
   https_proxy : http://127.0.0.1:37245/

Expected Behavior

_Tell us what should happen_

Actual Behavior

_Tell us what happens instead_

Steps to Reproduce

_Reproduce this issue; include code to reproduce, if relevant_

  1. ...
  2. ...
  3. ...
  4. ....

Context

_What were you trying to do?_

Debug logs

_Include iOS / Android logs_

  • ios XCode logs
  • Android: $ adb logcat

Most helpful comment

Thanks JapuDCret!

cordova plugin remove cordova-plugin-local-notification

cordova plugin add https://github.com/timkellypa/cordova-plugin-local-notifications.git

fixes this problem.

All 7 comments

this turned out to be a build fault. the build process' failure in loading some dependencies had caused this problems

how did you make that work???

I'm having this exact problem @jing-zhou, how did you fix it?

@idehweb , did you get it going?

I can recommend this fork: https://github.com/timkellypa/cordova-plugin-local-notifications
works fine now

Thanks JapuDCret!

cordova plugin remove cordova-plugin-local-notification

cordova plugin add https://github.com/timkellypa/cordova-plugin-local-notifications.git

fixes this problem.

no that is not a fix @danieleisenhardt @JapuDCret that repo crashes the app and their fix is to use this repo but this issue has build issues and the fix is to use that repo?????

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daniele-sartiano picture daniele-sartiano  路  4Comments

faytekin picture faytekin  路  3Comments

mino922 picture mino922  路  3Comments

makinhs picture makinhs  路  5Comments

ashvin777 picture ashvin777  路  3Comments