Cordova-plugin-local-notifications: error: cannot find symbol import android.app.NotificationChannel;

Created on 14 Dec 2017  路  11Comments  路  Source: katzer/cordova-plugin-local-notifications

Error at build time

Your Environment

  • Plugin version: 0.9.0-beta.1
  • Platform: Android
  • OS version: Android
  • Device manufacturer / model: AVD and LeEco 2
  • Cordova version (cordova -v): 7.0.1, 7.1.1
  • Cordova platform version (cordova platform ls): Android 4.4, 5.0, 6.1

Steps to Reproduce

  1. cordova create hello
  2. cd hello
  3. cordova platform add android
  4. cordova run android
    OK
  5. cordova plugin add cordova-plugin-splashscreen
  6. cordova run android
    OK
  7. cordova plugin add cordova-plugin-local-notification
  8. cordova run android
    ERROR

Debug logs

`ANDROID_HOME=H:\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144\
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_cx9qy3b4evn7wp86k28qfcrpr.run(H:\Git\hello\platformsandroidbuild.gradle:139)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseAidl UP-TO-DATE
:CordovaLib:compileReleaseNdk UP-TO-DATE
:CordovaLib:copyReleaseLint UP-TO-DATE
:CordovaLib:mergeReleaseShaders UP-TO-DATE
:CordovaLib:compileReleaseShaders UP-TO-DATE
:CordovaLib:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
:CordovaLib:packageReleaseRenderscript UP-TO-DATE
:CordovaLib:compileReleaseRenderscript UP-TO-DATE
:CordovaLib:generateReleaseResValues UP-TO-DATE
:CordovaLib:generateReleaseResources UP-TO-DATE
:CordovaLib:packageReleaseResources UP-TO-DATE
:CordovaLib:processReleaseManifest UP-TO-DATE
:CordovaLib:generateReleaseBuildConfig UP-TO-DATE
:CordovaLib:processReleaseResources UP-TO-DATE
:CordovaLib:generateReleaseSources UP-TO-DATE
:CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
:CordovaLib:processReleaseJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:CordovaLib:bundleRelease UP-TO-DATE
:prepareAndroidArchLifecycleRuntime100Library UP-TO-DATE
:prepareComAndroidSupportSupportCompat2610Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUi2610Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUtils2610Library UP-TO-DATE
:prepareComAndroidSupportSupportFragment2610Library UP-TO-DATE
:prepareComAndroidSupportSupportMediaCompat2610Library UP-TO-DATE
:prepareComAndroidSupportSupportV42610Library UP-TO-DATE
:prepareMeLeolinShortcutBadger1119Library UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:24: error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:41: error: cannot find symbol
import static android.os.Build.VERSION_CODES.O;
^
symbol: static O
location: class
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:109: error: cannot find symbol
if (SDK_INT < O)
^
symbol: variable O
location: class Manager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:112: error: cannot find symbol
NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
^
symbol: class NotificationChannel
location: class Manager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:112: error: cannot find symbol
NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
^
symbol: method getNotificationChannel(String)
location: variable mgr of type NotificationManager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:117: error: cannot find symbol
channel = new NotificationChannel(
^
symbol: class NotificationChannel
location: class Manager
Note: H:\Git\hello\platformsandroid\src\deappplant\cordova\plugin\localnotification\TriggerReceiver.java uses or overrides a deprecated API.
:compileDebugJavaWithJavac FAILED
Note: Recompile with -Xlint:deprecation for details.
6 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':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.

BUILD FAILED

Total time: 2.694 secs
Error: cmd: Command failed with exit code 1 Error output:
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:24: error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:41: error: cannot find symbol
import static android.os.Build.VERSION_CODES.O;
^
symbol: static O
location: class
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:109: error: cannot find symbol
if (SDK_INT < O)
^
symbol: variable O
location: class Manager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:112: error: cannot find symbol
NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
^
symbol: class NotificationChannel
location: class Manager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:112: error: cannot find symbol
NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
^
symbol: method getNotificationChannel(String)
location: variable mgr of type NotificationManager
H:\Git\hello\platformsandroid\src\deappplant\cordova\pluginnotification\Manager.java:117: error: cannot find symbol
channel = new NotificationChannel(
^
symbol: class NotificationChannel
location: class Manager
Note: H:\Git\hello\platformsandroid\src\deappplant\cordova\plugin\localnotification\TriggerReceiver.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
6 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':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.`

duplicate wontfix android

Most helpful comment

tired of ionic

All 11 comments

Also getting this, but only on PhoneGap build, locally it works normally

Any update on this? I am also stuck with this error.

i have the same error after iinstalling cordova-plugin-local-notification

Guys
For this moment Ionic Native does not support 0.9.* version of this plugin,聽which brings breaking changes.
I removed the installed one 0.9 then i installed the old stable version compatible with ionic:
de.appplant.cordova.plugin.local-notification
And it's working now :)
Source: https://stackoverflow.com/questions/47866467/no-virtual-method-getactivenotifications

@SaidMarar I am not using ionic-native wrapper for this as I already knew that it won't support the latest plugin. I am interested in using 0.9 version as it has more features than the 0.8.
I have created a POC for v0.9 and it worked well on ios, but getting the abovementioned error for android.
Is there a way to make it work in android?

Same error here :(

Closing since its a duplication. You need the lastest SDK to compile the plugin code even your runtime SDK is lower.

tired of ionic

Hi guys,

NotificationChannel was added in Android API level 26, so you need to change compileSdkVersion to 26 or above.

I had the same problem with cordova-plugin-firebase, but they knew the issue and created new branch and reverted the commit with NotificationChannel usage. With this plugin you can find the commit where it is used and add the previous commit as
"cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git#commit_hash_code"

check if you are running a version of cordova android < 6.3
cordova platform rm android
cordova platform add [email protected]

Was this page helpful?
0 / 5 - 0 ratings