在 Ionic 6 中执行失败的 capacitor-cordova-android-plugins:compileDebugJavaWithJavac
Execution Failed capacitor-cordova-android-plugins:compileDebugJavaWithJavac in Ionic 6
我正在使用 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
我已经尝试了互联网上的所有方法。也许我错过了什么。请帮我解决这个问题。谢谢
清理你的项目
运行 gradlew clean 在 andorid 目录下
然后 运行 下面的命令,它复制并粘贴你的节点模块包在 android 目录中,如果你使用电容器或 cordova 或离子 js
npx 上限同步
重要的一步
运行 npx jetify
如果你的本地机器上没有安装 jetify npm install jetifier
我将 cordova-plugin-file 从版本 7 降级到版本 6,它解决了问题!
我正在使用 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
我已经尝试了互联网上的所有方法。也许我错过了什么。请帮我解决这个问题。谢谢
清理你的项目
运行 gradlew clean 在 andorid 目录下
然后 运行 下面的命令,它复制并粘贴你的节点模块包在 android 目录中,如果你使用电容器或 cordova 或离子 js
npx 上限同步
重要的一步 运行 npx jetify
如果你的本地机器上没有安装 jetify npm install jetifier
我将 cordova-plugin-file 从版本 7 降级到版本 6,它解决了问题!