Android.support.v4.content does not exist - appFlow build issue

Our Ionic 5 app uses the Cordova fileOpener2 plugin to open up files that the user has downloaded on to their the device (pdf’s, images, docs etc) - I’m not aware of a Capacitor alternative so we are still having to use the Cordova plugin for this - is there an alternative?

When I build locally the app builds ok but when I build on AppFlow the build fails with the error

android.support.v4.content does not exist against the FileOpener2 plugin.

This appears to be because Capacitor 2 uses Android X for its support library dependencies.

The ionic docs suggest adding jetifier and running npx jetify so I have installed it and added the following to the package.json scripts section:

"postinstall": "npx jetify"

Unfortunately the builds still fail on AppFlow with an error of:

npm WARN lifecycle myApp@2.9.9~postinstall: cannot run in wd myApp@2.9.9 npx jetify (wd=/builds/myName/myApp)

I then noticed that the documentation for the fileOpener2 plugin suggests adding the following two plugins if your project uses Android X and that the problem should then go away:

cordova-plugin-androidx
cordova-plugin-androidx-adapter

However when I add these and try to build on AppFlow I get a failure with the original error again:

android.support.v4.content does not exist

Has anyone else had similar issues and found a solution?

I have a few questions really:

  1. Is there any capacitor alternative to the FileOpener2 plugin?
  2. Why do my local builds work when the AppFlow builds are failing?
  3. What is the preferred solution to getting round this issue - the jetifiy solution or the addition of the two Cordova plugins (not that either has worked for me)

Probably not the answer you’re looking for, but I found that trying to build in AppFlow simply doesn’t work with Capacitor. Too many broken plug ins.

I pretty much run all of my builds in Android Studio and XCode now. That way I can fix any plug in errors without depending on the plug in author to fix it.

It’s extremely frustrating to me to see the Ionic team building Ionic Studio and crap like that when so many useful plugins need to be ported over to Capacitor. Even the plug in’s they have only work 1/2 way (looking at you Camera plugin that doesn’t let me control the snap) Plugins are the lifeblood of Ionic and they need a LOT more focus.

1 Like

Thanks. Yes, not the answer I was hoping for. I’ve raised a support ticket with Ionic and am awaiting a response. I really hope we don’t have to give up on AppFlow because of this.

i’m having the same issue. please keep us posted. i experimented with having the build step include the jetify command "“build”: “npx jetifier && ng build” but ran into issues trying to do a production build.

I’ve been having conversations with the Ionic engineer over this and so far the advice has been to fork the fileOpener2 repo and get it working. I’m not really happy about doing this partly because I’m not exactly sure what to do but mainly because locally my builds work fine - if I add that plugin and then run npx jetify I can then do an Android build and it works. On AppFlow the builds fail with the support library error and in the log there is this warning saying that jetifier could not be run. So I’m really keen to know why it’s not running on AppFlow but working locally. We won’t be able to use AppFlow otherwise which would be a real shame as I like it.

any update on this? I’m having a bit similar issue.

Hi. I haven’t solved it yet but it looks like my post install is not running for Android builds. It runs jetify ok when I build for iOS (which is ironic because it’s only needed for Android). What’s your issue?

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:capacitor-cordova-android-plugins:compileReleaseJavaWithJavac’.

Compilation failed; see the compiler error output for details.

not sure though, it’s my first time.

I’m using ionic v5 btw with capacitor.

I bought the subscription for the easy deployment but apparently it’s not working.

I was able to build and publish using android studio, don’t know why ionic appflow’s giving my errors.

use

cordova plugin add cordova-plugin-androidx-adapter

I tried that and it didn’t work

I finally have this working. The solution was to place a .npmrc file in the root of the project with the following in it:

unsafe-perm=true

2 Likes