Ionic 4 capacitor application Release build crashing with java.lang.ClassNotFoundException: org.apache.cordova.file.FileUtils

Hello,

I have recently ported the Ionic 3 Application to Ionic 4.
But I am getting issue with an only the Release build, it is crashing as I open the application. below is the crash I get in logcat

Any idea what and why it is happening?

1-13 11:53:41.928  1977  1977 D Capacitor: Starting BridgeActivity
01-13 11:53:41.928  1977  1977 W System.err: java.lang.ClassNotFoundException: org.apache.cordova.file.FileUtils
01-13 11:53:41.928  1977  1977 W System.err:    at java.lang.Class.classForName(Native Method)
01-13 11:53:41.928  1977  1977 W System.err:    at java.lang.Class.forName(Class.java:453)
01-13 11:53:41.928  1977  1977 W System.err:    at java.lang.Class.forName(Class.java:378)
01-13 11:53:41.928  1977  1977 W System.err:    at g.a.a.o.e(Unknown Source:11)
01-13 11:53:41.928  1977  1977 W System.err:    at g.a.a.o.c(Unknown Source:30)
01-13 11:53:41.928  1977  1977 W System.err:    at g.a.a.o.n(Unknown Source:28)
01-13 11:53:41.928  1977  1977 W System.err:    at g.a.a.o.d(Unknown Source:22)
01-13 11:53:41.928  1977  1977 W System.err:    at com.getcapacitor.d0.c.q(Unknown Source:54)
01-13 11:53:41.928  1977  1977 W System.err:    at com.getcapacitor.c.I(Unknown Source:46)
01-13 11:53:41.928  1977  1977 W System.err:    at com.getcapacitor.c.H(Unknown Source:59)
01-13 11:53:41.928  1977  1977 W System.err:    at com.getcapacitor.c.G(Unknown Source:1)
01-13 11:53:41.928  1977  1977 W System.err:    at com.redtrucks.app.MainActivity.onCreate(Unknown Source:8)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.Activity.performCreate(Activity.java:7009)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.Activity.performCreate(Activity.java:7000)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.ActivityThread.-wrap11(Unknown Source:0)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
01-13 11:53:41.928  1977  1977 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:106)
01-13 11:53:41.928  1977  1977 W System.err:    at android.os.Looper.loop(Looper.java:164)
01-13 11:53:41.928  1977  1977 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6494)
01-13 11:53:41.928  1977  1977 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
01-13 11:53:41.928  1977  1977 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
01-13 11:53:41.928  1977  1977 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
01-13 11:53:41.928  1977  1977 W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.cordova.file.FileUtils" on path: DexPathList[[zip file "/data/app/com.redtrucks.app-jWWsOkHiDuz_3q2By8uQ1w==/base.apk"],nativeLibraryDirectories=[/data/app/com.redtrucks.app-jWWsOkHiDuz_3q2By8uQ1w==/lib/x86, /system/lib, /system/vendor/lib]]
01-13 11:53:41.929  1977  1977 W System.err:    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
01-13 11:53:41.929  1977  1977 W System.err:    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
01-13 11:53:41.929  1977  1977 W System.err:    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
01-13 11:53:41.929  1977  1977 W System.err:    ... 25 more
01-13 11:53:41.929  1977  1977 I System.out: Error adding plugin org.apache.cordova.file.FileUtils.
01-13 11:53:41.929  1977  1977 D AndroidRuntime: Shutting down VM
01-13 11:53:41.929  1977  1977 E AndroidRuntime: FATAL EXCEPTION: main
01-13 11:53:41.929  1977  1977 E AndroidRuntime: Process: com.redtrucks.app, PID: 1977
01-13 11:53:41.929  1977  1977 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.redtrucks.app/com.redtrucks.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void g.a.a.g.q(java.lang.String, g.a.a.e, g.a.a.j, g.a.a.h)' on a null object reference
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread.-wrap11(Unknown Source:0)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6494)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
01-13 11:53:41.929  1977  1977 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void g.a.a.g.q(java.lang.String, g.a.a.e, g.a.a.j, g.a.a.h)' on a null object reference
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at g.a.a.o.c(Unknown Source:42)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at g.a.a.o.n(Unknown Source:28)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at g.a.a.o.d(Unknown Source:22)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.getcapacitor.d0.c.q(Unknown Source:54)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.getcapacitor.c.I(Unknown Source:46)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.getcapacitor.c.H(Unknown Source:59)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.getcapacitor.c.G(Unknown Source:1)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at com.redtrucks.app.MainActivity.onCreate(Unknown Source:8)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:7009)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:7000)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
01-13 11:53:41.929  1977  1977 E AndroidRuntime:        ... 9 more
01-13 11:53:41.930   478  1824 W ActivityManager:   Force finishing activity com.redtrucks.app/.MainActivity
01-13 11:53:41.931   478   530 I ActivityManager: Showing crash dialog for package com.redtrucks.app u0

Theres an issue with this plugin.

Is this any known issue ??
How to point it out ? Can you please elaborate ?

Since you ported over your project, more than likely something broke. In this case it would be the file plugin you are using. I would suggest to remove the plugin and add it again to see if this fixes the error.

Actually i have 3 plugins package.json

    "@ionic-native/file": "^5.30.0",
    "@ionic-native/file-opener": "^5.27.0",
    "@ionic-native/file-transfer": "^5.30.0",

Do you know which one should be problem ? Meanwhile I will try removing all of them and re add them.

Also what is the correct way to remove plugin.

npm uninstall file

is this correct way ?