I am using Cordova plugin to use fileOpener in the capacitor ionic project. Before this, everything was working fine as I install following packages:
npm install @ionic-native/file
npm install cordova-plugin-file
npm install @ionic-native/file-opener
npm install cordova-plugin-file-opener2
Here is the error I am facing:
> Configure project :
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's sunset in
February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.4/userguide/upgrading_version_6.html#jcenter_deprecation
at build_dcpio6s66acap9ob7gfqiirhb$_run_closure1$_closure2.doCall(C:\Project\Ionic\mock-service\android\build.gradle:7)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
WARNING:: Using flatDirs should be avoided because it doesn't support any meta-data formats.
Currently detected usages:
- repository flatDir used in: project ':app', project ':capacitor-cordova-android-plugins'
WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: root project 'android', project ':app', project ':capacitor-android', ...
> Task :capacitor-android:compileDebugAidl NO-SOURCE
Relying on FileTrees for ignoring empty directories when using @SkipWhenEmpty has been deprecated. This is scheduled to be removed in Gradle 8.0. Annotate the property sourceFiles with @IgnoreEmptyDirectories or remove @SkipWhenEmpty. Consult the upgrading guide for further information: https://docs.gradle.org/7.4/userguide/upgrading_version_7.html#empty_directories_file_tree
> Task :app:compileDebugRenderscript NO-SOURCE
Relying on FileTrees for ignoring empty directories when using @SkipWhenEmpty has been deprecated. This is scheduled to be removed in Gradle 8.0. Annotate the property sourceDirs with @IgnoreEmptyDirectories or remove @SkipWhenEmpty. Consult the upgrading guide for further information: https://docs.gradle.org/7.4/userguide/upgrading_version_7.html#empty_directories_file_tree
> Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavac FAILED
C:\Project\Ionic\mock-service\android\capacitor-cordova-android-plugins\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 {
^
C:\Project\Ionic\mock-service\android\capacitor-cordova-android-plugins\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(android.content.Context,java.lang.String,java.io.File)
location: class io.github.pwlin.cordova.plugins.fileopener2.FileProvider
C:\Project\Ionic\mock-service\android\capacitor-cordova-android-plugins\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(android.content.Context,java.lang.String,java.io.File)
location: class io.github.pwlin.cordova.plugins.fileopener2.FileProvider
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Project\Ionic\mock-service\android\capacitor-cordova-android-plugins\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
70 actionable tasks: 1 executed, 69 up-to-date
Package.json:
"dependencies": {
"@angular/common": "~13.0.0",
"@angular/core": "~13.0.0",
"@angular/forms": "~13.0.0",
"@angular/platform-browser": "~13.0.0",
"@angular/platform-browser-dynamic": "~13.0.0",
"@angular/router": "~13.0.0",
"@capacitor/android": "3.4.1",
"@capacitor/app": "1.1.0",
"@capacitor/core": "3.4.1",
"@capacitor/haptics": "1.1.4",
"@capacitor/keyboard": "1.2.2",
"@capacitor/status-bar": "1.0.8",
"@ionic-native/file": "^5.36.0",
"@ionic-native/file-opener": "^5.36.0",
"@ionic/angular": "^6.0.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^3.0.5",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
Java Version:
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) Client VM (build 25.321-b07, mixed mode)
gradle Version:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
I have tried everything on the internet. Maybe I missed something. Please help me to fix this problem. Thank you
clean your project
Run gradlew clean in andorid directory
Then run below command ,it copies and paste your node module packages in android directory if your using capacitor or cordova or ionic js
npx cap sync
important step run npx jetify
if not jetify installed on your local machine npm install jetifier