我正在使用 cordova 插件使用fileOpener在电容器离子项目。在此之前,一切都工作正常,因为我安装了以下包:
npm install @ionic-native/file
npm install cordova-plugin-file
npm install @ionic-native/file-opener
npm install cordova-plugin-file-opener2
下面是我面临的错误:
> 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版本:
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版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
我已经尝试了互联网上的一切。也许我错过了什么。请帮助我修复这个问题。谢谢
2条答案
按热度按时间jecbmhm31#
清理项目
在andorid目录中运行gradlew clean
然后运行下面的命令,它复制并粘贴您的节点模块包在android目录中,如果您使用电容器或cordova或离子js
npx电容同步
重要步骤运行npx jetify
如果本地计算机上未安装jetifynpm安装jetifier
9fkzdhlc2#
我降级cordova插件文件从版本7到6,它解决了这个问题!
请参阅详细信息:https://github.com/ionic-team/capacitor/issues/5602