UncleMike
UncleMike

Reputation: 21

cordova-plugin-background-mode plugin used to work, but now the build crashes and the log appears to point to this plugin

cordova-plugin-background-mode plugin used to work in phonegap. I have had Android apps that have run for years with it. Now when I try a phonegap build, the same code that used to work, now will not create an APK. See log.

I have researched online, but no one else seems to be having this problem.

This is the last several lines in the Build Log:

    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/var/gimlet/tmp/47266562857200/2950595/project/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)
/var/gimlet/tmp/47266562857200/2950595/project/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)
/var/gimlet/tmp/47266562857200/2950595/project/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)
3 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.
    at ChildProcess.whenDone (/var/gimlet/tmp/47266562857200/2950595/project/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

Error messages are in the log file. I am using the online Phonegap build -- not the Cordova CLI.

Upvotes: 1

Views: 1185

Answers (2)

Liam Mazy
Liam Mazy

Reputation: 408

I solved the problem by reinstalling this plugin:

cordova plugin rm cordova-plugin-background-mode
cordova plugin add cordova-plugin-background-mode

Upvotes: 0

UncleMike
UncleMike

Reputation: 21

Had to add these lines in config.xml:

<preference name='phonegap-version' value='cli-9.0.0' /> <preference name='pgb-builder-version' value='1' /> <preference name="android-targetSdkVersion" value="28" />

This not only makes things work, it is also compliant with Google Play Store's new target API requirements. All apps must support Android 9.0 (API level 28) by November 1st.

Upvotes: 1

Related Questions