-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AndroidX support #256
Comments
Good news! dpa99c just released two plugins, one to enable AndroidX support, one to fill in the compatibility gap: dpa99c/cordova-diagnostic-plugin#350 (comment) |
hi @timbru31 thanks that's great news! I will try to look into that comment and merge the changes back in here. |
Hi is there any news on this issue? |
You can use the cordova-plugin-androidx-adapter and cordova-plugin-androidx plugins in the meantime to solve this issue |
that solved it for me, thank you |
@timbru31, @mg How do you go solving this issue? I have looked into the plugin mentioned but I am not sure what do you. Is this just a matter of changing the Update: Is #292 something that would completely fix this issue? |
No, I just installed the 2 plugins, that took care of it for me |
The plugins do two things:
As a plugin author, I'd do the following:
Users should be able to either just use cordova-android@9 or cordova-android@8 with cordova-plugin-androidx. |
This forces all your users to install two plugins from another author or wait until cordova-android@9 is released - or breaks the plugin for them in case they can't migrate to AndroidX (yet). |
Thank you for the explanation. I think at the moment the best way to handle this is to add |
Hi, I am having this issue as well but I am using Capacitor not Cordova. So I installed
to the following
I would imagine this change will be required for anyone who keeps there projects up to date with the latest technology. If not then they simply need to use the lock file and lock this package to where they need it. I will not be able to compile my application using CI/CD since I will need to manually come and change this code after every Ionic build. |
@StefanVanStaden Looks like using Jetifier with Capacitor has cut it for me. I just followed the instructions here: https://capacitorjs.com/docs/android/troubleshooting#error-package-android-support-does-not-exist In short, I ran: npm install jetifier
npx jetify
npx cap sync android And the subsequent automated builds ran correctly. |
Cordova 10.0.0 released with cordova-android@9.0.0: https://cordova.apache.org/announcements/2020/07/28/cordova-lib-release-10.0.0.html Now my build failed with cordova@10.0.0 and cordova-android@9.0.0. Required android.support.v4.content AndroidXEnabled = true |
When I build my Ionic 5 Capacitor app locally the app builds ok but when I build up on AppFlow the build fails with the error
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:
Unfortunately the builds still fail on AppFlow with an error of:
I then tried with these two plugins instead (as per the docs):
However when I add these and try to build on AppFlow I get a failure with the original error again:
Does this mean I am not going to be able to use this plugin with AppFlow? |
It is a blocked issue for me now! > Task :app:compileReleaseJavaWithJavac FAILED
/app/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileProvider.java:28: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {
^
/app/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java:119: error: cannot find symbol
path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
^
symbol: method getUriForFile(Context,String,File)
location: class FileProvider
/app/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java:127: error: cannot find symbol
Uri path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
^
symbol: method getUriForFile(Context,String,File)
location: class FileProvider
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
FAILURE: Build failed with an exception.
|
Any update or better fork for this? |
This worked for me. Without installing the androidx plugins (cordova-plugin-androidx and cordova-plugin-androidx-adapter) I ran those three commands and now my FileProvider class from cordova FileOpener2 extends androidx.core.content.FileProvider. Thanks! |
These 3 lines of codes from https://capacitorjs.com/docs/android/troubleshooting#error-package-android-support-does-not-exist |
Running @richardkshergold you seems found your solution here: https://forum.ionicframework.com/t/android-support-v4-content-does-not-exist-appflow-build-issue/194978 just need to link this thread :) |
@richardkshergold did you ever solve this for AppFlow? Am experiencing the same issue. Build manually works with the jetifier plugin etc but AppFlow fails |
Hi Kirsten. Yes I did with the help of an Ionic engineer. The solution was to place a .npmrc file in the root of the project with the following in it: unsafe-perm=true I hope that works for you too. |
@richardshergold thank you for your speedy reply. for anyone else, to summarise entire steps: As a workaround, you can patch the plugin using jetifier:
The jetifier should be in package.json file. You need to include a postinstall script in package.json for jetifier to run. This can be done as shown below:
In the file named .npmrc (create the file if not already present) in the root of your project, add the following contents. This will give npm running the jetifier script permissions. |
androidX is now supported in the latest release |
Expected Behaviour
The plugin is compatible with AndroidX (as discussed here: #251 (comment))
Actual Behaviour
Plugin is not compatible with AndroidX.
Reproduce Scenario (including but not limited to)
Steps to Reproduce
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
n/a
Cordova CLI info
Here is the output:
n/a
Plugin version
Here is the output:
2.2.0
Sample Code that illustrates the problem
The current code
[...] extends android.support.v4.content.FileProvider {
needs to be updated to
androidx.core.content.FileProvider
.This is a breaking change and will require a major version bump.
Logs taken while reproducing problem
n/a
Background info
Sadly, since Cordova plugins ship the
.java
instead of the.class
files the automatic migration (jettifier, see: https://developer.android.com/jetpack/androidx#using_androidx) does not work and the plugin authors need to update their plugins.The text was updated successfully, but these errors were encountered: