You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装cordova-plugin-file-transfer后Android构建失败求助

Fixing Cordova File Transfer Build Error: Missing FileUtils Class

Hey, let's tackle this build error you're hitting after adding the cordova-plugin-file-transfer plugin. First, let's recap your environment details to make sure we're aligned:

Ionic Environment Info

CLI Packages (C:\Users\jessica\AppData\Roaming\npm\node_modules)

@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0

Global Packages

cordova (Cordova CLI) : 8.0.0

Local Packages

@ionic/app-scripts : 3.0.1
Cordova Platforms : android 6.2.3 browser 5.0.1
Ionic Framework : ionic-angular 3.8.0

System

Android SDK Tools : 25.2.5
Node : v6.10.3
npm : 6.0.1
OS : Windows 8.1

Environment Variables

ANDROID_HOME : C:\Program Files (x86)\Android\android-sdk

Other

backend : legacy

The Root Cause

Looking at your build logs, the error boils down to:

error: package org.apache.cordova.file does not exist
import org.apache.cordova.file.FileUtils;

This happens because cordova-plugin-file-transfer has a hard dependency on cordova-plugin-file, but either:

  1. The cordova-plugin-file isn't installed in your project, or
  2. You have a version mismatch between the two plugins, or between the plugins and your older Cordova/Android setup (Cordova 8.0.0 + Android 6.2.3).

Newer versions of cordova-plugin-file removed the FileUtils class that file-transfer relies on, which is why the build fails.

Step-by-Step Fix

Here's how to resolve this by installing compatible plugin versions:

  1. Uninstall the existing file-transfer plugin (if needed)

    ionic cordova plugin remove cordova-plugin-file-transfer
    
  2. Install a compatible version of cordova-plugin-file
    For your Cordova 8.0.0 and Android 6.2.3 setup, version 6.0.2 is stable and works with the older FileUtils dependency:

    ionic cordova plugin add cordova-plugin-file@6.0.2
    
  3. Reinstall a compatible cordova-plugin-file-transfer version
    Version 1.7.1 is known to work with cordova-plugin-file@6.0.2 and your environment:

    ionic cordova plugin add cordova-plugin-file-transfer@1.7.1
    
  4. Clean and rebuild your Android project
    To clear any cached build artifacts and ensure the plugins are properly linked:

    # Remove the Android platform
    ionic cordova platform remove android
    # Re-add the exact Android version you were using
    ionic cordova platform add android@6.2.3
    # Clean build cache
    ionic cordova clean android
    # Rebuild the project
    ionic cordova build android
    

Extra Checks

  • Double-check your package.json to confirm both plugins are listed with the correct versions.
  • Verify the platforms/android/project.properties file includes a reference to cordova-plugin-file (it should be added automatically when installing the plugin).

This should resolve the missing FileUtils class error and let your build complete successfully.

内容的提问来源于stack exchange,提问作者user2828442

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:13:28