[英]Why doesn't the cordova-plugin-background-mode plugin work on android?
[英]cordova-plugin-background-mode plugin used to work, but now the build crashes and the log appears to point to this plugin
用於在 phonegap 中工作的 cordova-plugin-background-mode 插件。 我已經使用它運行了多年的 Android 應用程序。 現在,當我嘗試使用 phonegap 構建時,以前可以使用的代碼現在不會創建 APK。 見日志。
我在網上研究過,但似乎沒有其他人遇到這個問題。
這是構建日志中的最后幾行:
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)
錯誤消息在日志文件中。 我使用的是在線 Phonegap 構建——而不是 Cordova CLI。
必須在 config.xml 中添加這些行:
<preference name='phonegap-version' value='cli-9.0.0' /> <preference name='pgb-builder-version' value='1' /> <preference name="android-targetSdkVersion" value="28" />
這不僅使事情有效,而且還符合 Google Play 商店的新目標 API 要求。 到 11 月 1 日,所有應用都必須支持 Android 9.0(API 級別 28)。
我通過重新安裝這個插件解決了這個問題:
cordova plugin rm cordova-plugin-background-mode
cordova plugin add cordova-plugin-background-mode
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.