katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

Android Cordova Build Fail || IOS XCode nothing happend #1545

Closed BeMontelli closed 5 years ago

BeMontelli commented 6 years ago

My cordova build androidalways fail if an error maybe linked to my Android SDK Version This issue is the continuation of this issue: #1527

Your Environment

Expected Behavior

I would understand why my plugin doesn't work. The plugin build should succeed and my IOS build should display notifications

Actual Behavior

An error occures while i build my android App, and on IOS nothing is triggered with my build XCode

Steps to Reproduce

Reproduce this issue; include code to reproduce, if relevant

  1. cordova plugin add cordova-plugin-local-notification
  2. is added to config
  3. cordova build android

Context

SDK Platforms installed: Android : 8.0 Android :7.1.1 Android : 7.0

SDK Tools: Android SDK Platform - Tools : 27.0.1 Android SDK Tools : 26.1.1

How can i know which version is used by Cordova ?

My code:

(onDeviceReady)

if (window.hasOwnProperty('cordova')) {
          cordova.plugins.notification.local.registerPermission(function (granted) {
            console.log("promptForPermission: "+granted);
            var notifications = [];
                        var notificationUnique = {
                            id: 123,
                            at: (new Date()).getTime(),
                            text: "text",
                            title: "title"
                        };

                        notificationUnique.sound = null;
                        notificationUnique.data = null;

                        notifications.push(notificationUnique);

                        cordova.plugins.notification.local.registerPermission(function (granted) {
                            if(granted){
                                console.log("Permission : "+granted);
                                if (notifications.length) {
                                    console.log("Length Notifications : "+notifications.length);
                                    cordova.plugins.notification.local.cancelAll(function () {
                                        console.log("cancelAll");
                                        cordova.plugins.notification.local.schedule(notifications);
                                    });
                                } else {
                                    console.log("there were no reminders in notifications to schedule");
                                }
                            }
                        });
          });
        }

Debug logs

Error: /platforms/android/gradlew: Command failed with exit code 1 Error output:
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:25: error: cannot find symbol
import android.app.NotificationChannel;
                  ^
  symbol:   class NotificationChannel
  location: package android.app
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:43: error: cannot find symbol
import static android.os.Build.VERSION_CODES.O;
^
  symbol:   static O
  location: class
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:112: error: cannot find symbol
        if (SDK_INT < O)
                      ^
  symbol:   variable O
  location: class Manager
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:115: error: cannot find symbol
        NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
        ^
  symbol:   class NotificationChannel
  location: class Manager
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:115: error: cannot find symbol
        NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);
                                         ^
  symbol:   method getNotificationChannel(String)
  location: variable mgr of type NotificationManager
/platforms/android/src/de/appplant/cordova/plugin/notification/Manager.java:120: error: cannot find symbol
        channel = new NotificationChannel(
                      ^
  symbol:   class NotificationChannel
  location: class Manager
Note: /platforms/android/src/de/appplant/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.

Thanks for your help

katzer commented 6 years ago

@BeMontelli

  1. The error logs says that the SDK for Android 8 isn't available - at least not for compilation.
  2. Based on your code sample - if you use 0.9-beta but the code is not compatible with 0.9. I know there's no changelog or migration steps yet. However the README covers the common things how to do with v0.9
BeMontelli commented 6 years ago

Hello,

I tried this command: export ORG_GRADLE_PROJECT_cdvCompileSdkVersion=android-26, on an other system the build succeed but on mine a new error appeared:

/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/prod-purmo/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml:79:35-72: AAPT: No resource found that matches the given name (at 'resource' with value '@xml/localnotification_provider_paths').

/prod-purmo/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml:77: error: Error: No resource found that matches the given name (at 'resource' with value '@xml/localnotification_provider_paths').

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
cerw commented 6 years ago

Same problem in docker

BeMontelli commented 5 years ago

Hi,

I solved this problem by updating my current SdkVersion

Here is the line: export ORG_GRADLE_PROJECT_cdvCompileSdkVersion=android-26