Open BuddyLReno opened 5 years ago
Ok it looks like I just need to set source and target compatibility versions to 1.8 in Android Studio 👍 I'll leave this open for now in case other people stumble across this issue.
Still i'm facing the same issue in Cordova-Android 6.4.0. The automated builds won't work with the above fix. is there any thing we can do now? if we don't use the URL (https://github.com/katzer/cordova-plugin-background-mode.git) to install this plugin then the plugin works fine in Android but iOS build is crashed when open the app, might be due to a key change done in this plugin a year ago.
Now using this URL the plugin works fine in iOS but android build is not passing. Please let us know if we can make some workaround to both platform with a fix?
Same error here with cordova-android 7.1.4
At least this iOS Crash fix should be merged to repo located at npmjs.
Feel free to fork my fork. Adds support for older Cordova versions.
How do I install this to visual studio 2017?
@boedy i tried your fork on android6.4 but it's not working. Same error
@mehmetkaynak @casper123
This works for me when trying it on a new empty project:
cordova create background-mode-test
cd background-mode-test
cordova platform add android@6.3.0
cordova plugin add https://github.com/boedy/cordova-plugin-background-mode/
cordova build android
I'm still on Cordova version 6.5.0
. Not sure if that impacts anything.
I solved the problem by reinstalling this plugin:
cordova plugin rm cordova-plugin-background-mode
cordova plugin add cordova-plugin-background-mode
I have the same issue with Cordova 6.5.0
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/BackgroundModeExt.java:168: error: lambda expressions are not supported in -source 1.6
getApp().runOnUiThread(() -> {
^
(use -source 8 or higher to enable lambda expressions)
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/BackgroundModeExt.java:257: error: method references are not supported in -source 1.6
activity.runOnUiThread(dialog::show);
^
(use -source 8 or higher to enable method references)
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/BackgroundMode.java:295: error: lambda expressions are not supported in -source 1.6
cordova.getActivity().runOnUiThread(() -> webView.loadUrl("javascript:" + js));
^
(use -source 8 or higher to enable lambda expressions)
3 errors
:compileDebugJavaWithJavac FAILED
@mehmetkaynak @casper123
This works for me when trying it on a new empty project:
cordova create background-mode-test cd background-mode-test cordova platform add android@6.3.0 cordova plugin add https://github.com/boedy/cordova-plugin-background-mode/ cordova build android
I'm still on Cordova version
6.5.0
. Not sure if that impacts anything.
I get this error with your fork when compiling with API 28:
error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/ForegroundService.java:184: error: cannot find symbol
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name,importance);
^
symbol: class NotificationChannel
location: class ForegroundService
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/ForegroundService.java:184: error: cannot find symbol
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name,importance);
^
symbol: class NotificationChannel
location: class ForegroundService
/Users/mirko/Sites/epicollect5-mobile-app-legacy/platforms/android/src/de/appplant/cordova/plugin/background/ForegroundService.java:207: error: cannot find symbol
notification.setChannelId(CHANNEL_ID);
^
symbol: method setChannelId(String)
location: variable notification of type Builder
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
It looks like since this commit here (6b522e9832ba2dcd40b3820d9900db07a29b8aa0), some specific java features that are only enabled in android 7 and 8 were added (like Lambdas). This breaks the plugin on apps that still support android 6.
Would it be possible to amend the lambdas and other android 7 and 8 specific features to keep compatibility with android 6?
Here's an example of some of the build errors: