【问题标题】:Cordova plugin conflict between file-transfer and whitelist文件传输和白名单之间的 Cordova 插件冲突
【发布时间】:2023-01-03 02:18:58
【问题描述】:

文件传输和白名单插件之间似乎存在冲突,其他一些用户也报告了这一点。我的插件列表如下(还需要安装几个):

cordova-plugin-android-permissions 1.1.5 "Permissions"
cordova-plugin-app-event 1.2.2 "Application Events"
cordova-plugin-device 2.1.0 "Device"
cordova-plugin-file-md5 0.3.3 "MD5 Checksum"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-file 7.0.0 "File"
cordova-plugin-inappbrowser 5.0.0 "InAppBrowser"
cordova-plugin-launcher 0.2.2 "Launcher"
cordova-plugin-media 6.1.0 "Media"
cordova-plugin-network-information 3.0.0 "Network Information"
cordova-plugin-splashscreen 6.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.5 "Whitelist"
cordova-plugin-x-socialsharing 6.0.4 "SocialSharing"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
es6-promise-plugin 4.2.2 "Promise"

安装 cordova-plugin-file-transfer 后,构建拒绝完成其工作并出现以下错误:

D:\PhoneGap\qforall\platforms\android\app\src\main\java\org\apache\cordova\filetransfer\FileTransfer.java:48: error: cannot find symbol
import org.apache.cordova.Whitelist;
                         ^
  symbol:   class Whitelist
  location: package org.apache.cordova
D:\PhoneGap\qforall\platforms\android\app\src\main\java\org\apache\cordova\filetransfer\FileTransfer.java:691: error: cannot find symbol
                Whitelist whitelist = (Whitelist)gwl.invoke(webView);
                ^
  symbol:   class Whitelist
  location: class org.apache.cordova.filetransfer.FileTransfer
D:\PhoneGap\qforall\platforms\android\app\src\main\java\org\apache\cordova\filetransfer\FileTransfer.java:691: error: cannot find symbol
                Whitelist whitelist = (Whitelist)gwl.invoke(webView);
                                       ^
  symbol:   class Whitelist
  location: class org.apache.cordova.filetransfer.FileTransfer
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.
3 errors

我还尝试按照@Siddhartha Mukherjee 建议的in this 帖子将白名单替换为白名单,但这也给出了相同的cannot find symbol 错误。

它早些时候工作得很好,但是当我用最新的 Cordova 和 Gradle 为最新的 Android 创建一个新项目时,它就停止了。任何帮助,将不胜感激。

【问题讨论】:

    标签: android cordova plugins file-transfer whitelist


    【解决方案1】:

    您使用的是哪个版本的 cordova-android?白名单包含在 cordova-android 10+ 中,因此您应该删除该插件。 这确实破坏了 cordova-plugin-filetrasfer。要解决这个问题,您有两种选择。 1:我这样做了,用一个钩子删除了对白名单的所有引用。 2:更容易的是从 git 而不是 NPM 下载插件。开发者已经删除了主分支上对白名单的引用,但没有用它做一个标签/发布,所以它没有在 NPM 上更新。

    另请参阅此 SO 问题:android 10 doesn't support whitelist plugin

    git repo 中的这个问题:https://github.com/apache/cordova-plugin-file-transfer/issues/345

    【讨论】:

      猜你喜欢
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      • 2011-07-03
      • 2013-12-20
      • 1970-01-01
      相关资源
      最近更新 更多