生成 apk 时出现 Cordova-plugin-file 错误

Posted

技术标签:

【中文标题】生成 apk 时出现 Cordova-plugin-file 错误【英文标题】:Cordova-plugin-file error while generating apk 【发布时间】:2019-04-06 16:05:23 【问题描述】:

生成 APK 时出错 * 为 android 安装“cordova-plugin-file-transfer” 使用该版本已获取插件依赖项“cordova-plugin-file@4.3.3”。 依赖插件“cordova-plugin-file”已经安装在 android 上。 为 android 安装“cordova-plugin-filepath” 为 android 安装“cordova-plugin-geolocation” 使用该版本已获取插件依赖项“cordova-plugin-compat@1.2.0”。 为 android 安装“cordova-plugin-compat” 插件不支持该项目的 cordova-android 版本。 cordova-android:6.4.0,失败的版本要求:

Cordova-plugin-list

cordova 插件列表 com.moust.cordova.videoplayer 1.0.1 “视频播放器” 科尔多瓦插件电池状态 2.0.2“电池” 科尔多瓦插件相机 2.4.1 “相机” 科尔多瓦插件兼容 1.2.0 “兼容” 科尔多瓦插件控制台 1.0.5“控制台” 科尔多瓦插件设备 1.1.4 “设备” 科尔多瓦插件文件 4.3.3 “文件” cordova-plugin-file-transfer 1.6.3 “文件传输” 科尔多瓦插件文件路径 1.0.2 “文件路径” 科尔多瓦插件地理定位 2.4.3 “地理定位” cordova-plugin-ionic-webview 1.2.1 “cordova-plugin-ionic-webview” 科尔多瓦插件媒体捕获 1.4.3 “捕获” cordova-plugin-network-information 1.3.3 “网络信息” 科尔多瓦插件闪屏 4.0.3 “闪屏” 科尔多瓦插件状态栏 2.2.2 “状态栏” 科尔多瓦插件白名单 1.3.1 “白名单” cordova-plugin-wkwebview-engine 1.1.4-dev "Cordova WKWebView 引擎" cordova-sqlite-storage 2.0.4 “Cordova s​​qlite 存储插件” ionic-plugin-keyboard 2.2.1 “键盘” nl.x-services.plugins.videocaptureplus 1.0.0 "VideoCapturePlus" phonegap-plugin-barcodescanner 7.1.2 “条形码扫描仪” phonegap-plugin-push 1.10.5 “PushPlugin” *

Package.json

  "dependencies": 
    "@agm/core": "^1.0.0-beta.3",
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/barcode-scanner": "^4.4.2",
    "@ionic-native/battery-status": "^4.15.0",
    "@ionic-native/camera": "^4.13.0",
    "@ionic-native/core": "^4.1.0",
    "@ionic-native/file": "^4.14.0",
    "@ionic-native/file-path": "^4.1.0",
    "@ionic-native/file-transfer": "^4.13.0",
    "@ionic-native/geolocation": "^4.4.2",
    "@ionic-native/keyboard": "3.4.4",
    "@ionic-native/media": "^4.14.0",
    "@ionic-native/media-capture": "^4.14.0",
    "@ionic-native/network": "^4.3.2",
    "@ionic-native/splash-screen": "^3.4.4",
    "@ionic-native/status-bar": "3.4.4",
    "@ionic-native/transfer": "^3.14.0",
    "@ionic-native/video-capture-plus": "^4.13.0",
    "@ionic-native/video-player": "^4.14.0",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "^2.0.1",
    "@types/cordova-plugin-battery-status": "^1.2.3",
    "@types/cordova-plugin-media": "^3.0.0",
    "@types/ionic": "^3.19.0",
    "@types/underscore": "^1.8.9",
    "angular2-signaturepad": "^2.6.1",
    "babel-runtime": "^6.26.0",
    "backo2": "^1.0.2",
    "component-bind": "^1.0.0",
    "cordova": "^8.1.2",
    "cordova-android": "6.4.0",
    "cordova-ios": "~4.3.1",
    "cordova-plugin-battery-status": "^2.0.2",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "~1.0.6",
    "cordova-plugin-device": "~1.1.5",
    "cordova-plugin-file-transfer": "~1.6.3",
    "cordova-plugin-geolocation": "~2.4.3",
    "cordova-plugin-media": "^5.0.2",
    "cordova-plugin-media-capture": "^1.4.3",
    "cordova-plugin-splashscreen": "~4.0.2",
    "cordova-plugin-statusbar": "~2.2.2",
    "cordova-plugin-video-capture-plus": "^1.0.0",
    "cordova-plugin-video-player": "git+https://github.com/moust/cordova-plugin-videoplayer.git",
    "cordova-plugin-whitelist": "~1.3.2",
    "cordova-plugin-wkwebview-engine": "https://github.com/driftyco/cordova-plugin-wkwebview-engine.git",
    "cordova-sqlite-storage": "~2.0.3",
    "engine.io-client": "^3.1.4",
    "font-awesome": "^4.7.0",
    "has-binary": "^0.1.7",
    "ionic": "^4.1.2",
    "ionic-angular": "3.0.1",
    "ionic-image-loader": "^4.1.1",
    "ionic-img-viewer": "^1.3.4",
    "ionic-plugin-keyboard": "~2.2.1",
    "ionicons": "3.0.0",
    "isobject": "^3.0.1",
    "jquery": "^3.2.1",
    "lodash": "^4.17.4",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.13",
    "parseuri": "0.0.5",
    "phonegap-plugin-barcodescanner": "^7.0.0",
    "phonegap-plugin-push": "~1.10.5",
    "reflect-metadata": "^0.1.10",
    "rxjs": "5.1.1",
    "setimmediate": "^1.0.5",
    "signature_pad": "^2.3.2",
    "socket.io-client": "^1.7.3",
    "socket.io-parser": "^3.1.2",
    "sw-toolbox": "3.4.0",
    "to-array": "^0.1.4",
    "underscore": "^1.9.1",
    "zone.js": "^0.8.4"
  ,
  "devDependencies": 
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic/app-scripts": "1.3.0",
    "@ionic/cli-plugin-cordova": "1.6.2",
    "@ionic/cli-plugin-ionic-angular": "1.4.1",
    "@types/lodash": "^4.14.62",
    "@types/moment-timezone": "^0.2.34",
    "@types/socket.io-client": "^1.4.29",
    "typescript": "~2.2.1"
  ,
  "cordova": 
    "platforms": [
      "android",
      "ios"
    ],
    "plugins": 
      "cordova-plugin-console": ,
      "cordova-plugin-device": ,
      "cordova-plugin-splashscreen": ,
      "cordova-plugin-statusbar": ,
      "cordova-plugin-whitelist": ,
      "cordova-plugin-wkwebview-engine": ,
      "cordova-sqlite-storage": ,
      "ionic-plugin-keyboard": ,
      "phonegap-plugin-push": 
        "SENDER_ID": "694054568313"
      ,
      "cordova-plugin-media-capture": ,
      "phonegap-plugin-barcodescanner": 
        "CAMERA_USAGE_DESCRIPTION": " "
      ,
      "cordova-plugin-file-transfer": ,
      "cordova-plugin-geolocation": 
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      ,
      "com.moust.cordova.videoplayer": ,
      "cordova-plugin-camera": ,
      "cordova-plugin-media": ,
      "cordova-plugin-file": ,
      "cordova-plugin-battery-status": 
    
  

【问题讨论】:

【参考方案1】:

您似乎安装了多个版本的插件 - 4.3.3 和 6.0.0

ionic cordova plugin rm cordova-plugin-file
ionic cordova platform rm android
ionic cordova plugin add cordova-plugin-file
ionic cordova platform add android

如果你需要特定版本的插件,可以在add命令的末尾添加为

ionic cordova plugin add cordova-plugin-file@6.0.0

【讨论】:

以上是关于生成 apk 时出现 Cordova-plugin-file 错误的主要内容,如果未能解决你的问题,请参考以下文章

生成APK(签名)升级gradle版本时出现问题

生成 apk 文件时出现错误“未找到 DEX 文件”

生成 apk 时出现 Cordova-plugin-file 错误

从 Mobilefirst 生成 APK 后尝试登录时出现错误 Unresponsive_Host

在 Eclipse 中生成 APK 时出现“未找到 DEX 文件”错误

使用 Android Studio 签署 APK 时出现 Proguard 错误