错误警告:应避免使用 flatDirs,因为它不支持任何元数据格式

ada*_*000 0 android gradle android-studio ionic-framework capacitor

我的 Ionic/Angular 项目在 Android 上运行时遇到问题。尝试使用全新安装的 Node、Angular、Ionic、Android studio、Ionic 的新项目(选项卡)来排除故障。

\n

仍然无法运行,我\xe2\x80\x99已经卡了两天了。我现在收到以下错误。

\n
npx cap run android  --stacktrace --info\n\xe2\x88\x9a Copying web assets from www to android\\app\\src\\main\\assets\\public in 3.40s\n\xe2\x88\x9a Creating capacitor.config.json in android\\app\\src\\main\\assets in 3.15ms\n\xe2\x88\x9a copy android in 3.48s\n\xe2\x88\x9a Updating Android plugins in 10.59ms\n[info] Found 4 Capacitor plugins for android:\n       @capacitor/app@1.0.3\n       @capacitor/haptics@1.0.3\n       @capacitor/keyboard@1.0.3\n       @capacitor/status-bar@1.0.3\n\xe2\x88\x9a update android in 148.19ms\n\xc3\x97 Running Gradle build - failed!\n[error] WARNING:: Using flatDirs should be avoided because it doesn't support any meta-data formats.\n        Currently detected usages:\n        - repository flatDir used in: project ':capacitor-cordova-android-plugins'\n        WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and   \n        migrate your build to other Maven repositories.\n        This repository is deprecated and it will be shut down in the future.\n        See http://developer.android.com/r/tools/jcenter-end-of-service for more information.        \n        Currently detected usages in: project ':capacitor-android', project ':capacitor-app', project        ':capacitor-cordova-android-plugins', ...\n        Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns    \n        http://schemas.android.com/repository/android/common/01\n        Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns   \n        http://schemas.android.com/repository/android/generic/01\n        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns      \n        http://schemas.android.com/sdk/android/repo/addon2/01\n        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns \n        http://schemas.android.com/sdk/android/repo/repository2/01\n        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns    \n        http://schemas.android.com/sdk/android/repo/sys-img2/01\n        > Task :app:preBuild UP-TO-DATE\n        > Task :app:preDebugBuild UP-TO-DATE\n        > Task :capacitor-android:preBuild UP-TO-DATE\n        > Task :capacitor-android:preDebugBuild UP-TO-DATE\n        > Task :capacitor-android:compileDebugAidl NO-SOURCE\n        > Task :capacitor-app:preBuild UP-TO-DATE\n        > Task :capacitor-app:preDebugBuild UP-TO-DATE\n        > Task :capacitor-app:compileDebugAidl NO-SOURCE\n        > Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE\n        > Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE\n        > Task :capacitor-cordova-android-plugins:compileDebugAidl NO-SOURCE\n        > Task :capacitor-haptics:preBuild UP-TO-DATE\n        > Task :capacitor-haptics:preDebugBuild UP-TO-DATE\n        > Task :capacitor-haptics:compileDebugAidl NO-SOURCE\n        > Task :capacitor-keyboard:preBuild UP-TO-DATE\n        > Task :capacitor-keyboard:preDebugBuild UP-TO-DATE\n        > Task :capacitor-keyboard:compileDebugAidl NO-SOURCE\n        > Task :capacitor-status-bar:preBuild UP-TO-DATE\n        > Task :capacitor-status-bar:preDebugBuild UP-TO-DATE\n        > Task :capacitor-status-bar:compileDebugAidl NO-SOURCE\n        > Task :app:compileDebugAidl NO-SOURCE\n        > Task :capacitor-android:packageDebugRenderscript NO-SOURCE\n        > Task :capacitor-app:packageDebugRenderscript NO-SOURCE\n        > Task :capacitor-cordova-android-plugins:packageDebugRenderscript NO-SOURCE\n        > Task :capacitor-haptics:packageDebugRenderscript NO-SOURCE\n        > Task :capacitor-keyboard:packageDebugRenderscript NO-SOURCE\n        > Task :capacitor-status-bar:packageDebugRenderscript NO-SOURCE\n        > Task :app:compileDebugRenderscript NO-SOURCE\n        > Task :app:generateDebugBuildConfig UP-TO-DATE\n        > Task :app:javaPreCompileDebug UP-TO-DATE\n        > Task :capacitor-android:writeDebugAarMetadata UP-TO-DATE\n        > Task :capacitor-app:writeDebugAarMetadata UP-TO-DATE\n        > Task :capacitor-haptics:writeDebugAarMetadata UP-TO-DATE\n        > Task :capacitor-keyboard:writeDebugAarMetadata UP-TO-DATE\n        > Task :capacitor-status-bar:writeDebugAarMetadata UP-TO-DATE\n        > Task :app:generateDebugResValues UP-TO-DATE\n        > Task :app:generateDebugResources UP-TO-DATE\n        > Task :capacitor-cordova-android-plugins:writeDebugAarMetadata\n        > Task :app:processDebugGoogleServices FAILED\n\n        Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.  \n        Use '--warning-mode all' to show the individual deprecation warnings.\n        See\n        https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings  \n        10 actionable tasks: 2 executed, 8 up-to-date\n\n        FAILURE: Build failed with an exception.\n\n        * What went wrong:\n        Execution failed for task ':app:processDebugGoogleServices'.\n        > No matching client found for package name 'io.ionic.starter'\n\n        * Try:\n        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.\n\n        * Get more help at https://help.gradle.org\n\n        BUILD FAILED in 3s\n
Run Code Online (Sandbox Code Playgroud)\n

我可以看到的问题是,尽管 root build.gradle 和 app build.gradle 已经进行了错误中列出的更改,但它引用的电容器-cordova-android-plugins 文件夹正在每个构建中重建。这真是让我抓狂。

\n

帮助表示感谢!

\n

小智 5

我目前正在开发一个 ionic/Angular 项目,我也犯了和你一样的错误。我做了什么:

  1. 关闭 Android Studio。
  2. 从我的项目中删除 android 和 ios 文件夹
  3. 进行构建 ( ionic build)。
  4. npx cap add ios
  5. npx cap add android
  6. npx cap update
  7. 重新启动 Android Studio