Open dariov1988 opened 2 months ago
When I add the plugin to my project with:
cordova plugin add https://github.com/FWiner/cordova-plugin-android-background-mode
and try to build it, I get the following error:/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:36: error: cannot find symbol import android.support.v4.app.NotificationCompat; ^ symbol: class NotificationCompat location: package android.support.v4.app /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:38: error: cannot find symbol import android.support.v4.app.NotificationManagerCompat; ^ symbol: class NotificationManagerCompat location: package android.support.v4.app /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:346: error: package NotificationCompat does not exist private void setColor(NotificationCompat.Builder notification, ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:204: error: package NotificationCompat does not exist NotificationCompat.Builder notification = new NotificationCompat.Builder(context, CHANNEL_ID) ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:204: error: package NotificationCompat does not exist NotificationCompat.Builder notification = new NotificationCompat.Builder(context, CHANNEL_ID) ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:220: error: package NotificationCompat.Action does not exist NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent); ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:220: error: package NotificationCompat.Action does not exist NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent); ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:230: error: package NotificationCompat does not exist new NotificationCompat.BigTextStyle().bigText(text)); ^ /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:341: error: cannot find symbol NotificationManagerCompat notification = NotificationManagerCompat.from(activity); ^ symbol: class NotificationManagerCompat location: class BackgroundModeExt /platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:341: error: cannot find symbol NotificationManagerCompat notification = NotificationManagerCompat.from(activity); ^ symbol: variable NotificationManagerCompat location: class BackgroundModeExt Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 10 errors FAILURE: Build failed with an exception.
Cordova version: 12
Please let me know if more information is required. Thanks!
Hi dariov , i was tried to install this plugin to a clear cordova project(cordova version 12 , cordova-android 12), it seems like work fine. Can you post the specific screenshots of the errors and the plugin list?
Hi @FWiner, thanks for answering, here are the steps to reproduce the problem:
Create an empty app:
cordova create hello com.example.hello HelloWorld
Add the Android platform:
cordova platform add android
Check requirements (optional):
cordova requirements
Requirements check results for android:
Java JDK: installed 17.0.10
Android SDK: installed true
Android target: installed android-34,android-33
Gradle: installed /usr/share/java/gradle/bin/gradle
Add the background plugin:
cordova plugin add https://github.com/FWiner/cordova-plugin-android-background-mode
Check the plugin list (optional):
cordova plugin list
cordova-plugin-background-mode 0.7.3 "BackgroundMode"
cordova-plugin-device 2.1.0 "Device"
Try to build the project for Android:
cordova build android
Checking Java JDK and Android SDK versions
ANDROID_HOME=~/Android/Sdk (recommended setting)
ANDROID_SDK_ROOT=undefined (DEPRECATED)
Using Android SDK: ~/Android/Sdk
Subproject Path: CordovaLib
Subproject Path: app
> Task :app:compileDebugJavaWithJavac FAILED
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:36: error: cannot find symbol
import android.support.v4.app.NotificationCompat;
^
symbol: class NotificationCompat
location: package android.support.v4.app
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:38: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
^
symbol: class NotificationManagerCompat
location: package android.support.v4.app
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:346: error: package NotificationCompat does not exist
private void setColor(NotificationCompat.Builder notification,
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:204: error: package NotificationCompat does not exist
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, CHANNEL_ID)
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:204: error: package NotificationCompat does not exist
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, CHANNEL_ID)
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:220: error: package NotificationCompat.Action does not exist
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:220: error: package NotificationCompat.Action does not exist
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/ForegroundService.java:230: error: package NotificationCompat does not exist
new NotificationCompat.BigTextStyle().bigText(text));
^
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:341: error: cannot find symbol
NotificationManagerCompat notification = NotificationManagerCompat.from(activity);
^
symbol: class NotificationManagerCompat
location: class BackgroundModeExt
~/hello/platforms/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java:341: error: cannot find symbol
NotificationManagerCompat notification = NotificationManagerCompat.from(activity);
^
symbol: variable NotificationManagerCompat
location: class BackgroundModeExt
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
10 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.
> 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 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 737ms
27 actionable tasks: 1 executed, 26 up-to-date
Command failed with exit code 1: ~/hello/platforms/android/gradlew -b ~/hello/platforms/android/build.gradle cdvBuildDebug
If I remove the plugin:
cordova plugin remove cordova-plugin-background-mode
Uninstalling 1 dependent plugins.
Uninstalling cordova-plugin-device from android
Uninstalling cordova-plugin-background-mode from android
Subproject Path: CordovaLib
Subproject Path: app
Removing "cordova-plugin-background-mode"
Removing cordova-plugin-background-mode from package.json
And then try to build, it build correctly:
cordova build android
Checking Java JDK and Android SDK versions
ANDROID_HOME=~/Android/Sdk (recommended setting)
ANDROID_SDK_ROOT=undefined (DEPRECATED)
Using Android SDK: ~/Android/Sdk
Subproject Path: CordovaLib
Subproject Path: app
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
50 actionable tasks: 13 executed, 37 up-to-date
Built the following apk(s):
~/hello/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Thanks for your time and effort, have a nice day/night...
When I add the plugin to my project with:
cordova plugin add https://github.com/FWiner/cordova-plugin-android-background-mode
and try to build it, I get the following error:Cordova version: 12
Please let me know if more information is required. Thanks!