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

error WARNING: Using flatDirs should be avoided because it doesn't support any meta-data formats

我的 Ionic/Angular 项目 运行ning 在 Android 上遇到问题。尝试通过全新安装的 Node、Angular、Ionic、Android studio、Ionic 的新项目(选项卡)来解决问题。

还是不会 运行 我已经坚持了两天了。我现在收到以下错误。

npx cap run android  --stacktrace --info
√ Copying web assets from www to android\app\src\main\assets\public in 3.40s
√ Creating capacitor.config.json in android\app\src\main\assets in 3.15ms
√ copy android in 3.48s
√ Updating Android plugins in 10.59ms
[info] Found 4 Capacitor plugins for android:
       @capacitor/app@1.0.3
       @capacitor/haptics@1.0.3
       @capacitor/keyboard@1.0.3
       @capacitor/status-bar@1.0.3
√ update android in 148.19ms
× Running Gradle build - failed!
[error] WARNING:: Using flatDirs should be avoided because it doesn't support any meta-data formats.
        Currently detected usages:
        - repository flatDir used in: 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: project ':capacitor-android', project ':capacitor-app', project        ':capacitor-cordova-android-plugins', ...
        Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns    
        http://schemas.android.com/repository/android/common/01
        Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns   
        http://schemas.android.com/repository/android/generic/01
        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns      
        http://schemas.android.com/sdk/android/repo/addon2/01
        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns 
        http://schemas.android.com/sdk/android/repo/repository2/01
        Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns    
        http://schemas.android.com/sdk/android/repo/sys-img2/01
        > Task :app:preBuild UP-TO-DATE
        > Task :app:preDebugBuild UP-TO-DATE
        > Task :capacitor-android:preBuild UP-TO-DATE
        > Task :capacitor-android:preDebugBuild UP-TO-DATE
        > Task :capacitor-android:compileDebugAidl NO-SOURCE
        > Task :capacitor-app:preBuild UP-TO-DATE
        > Task :capacitor-app:preDebugBuild UP-TO-DATE
        > Task :capacitor-app:compileDebugAidl NO-SOURCE
        > Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE
        > Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE
        > Task :capacitor-cordova-android-plugins:compileDebugAidl NO-SOURCE
        > Task :capacitor-haptics:preBuild UP-TO-DATE
        > Task :capacitor-haptics:preDebugBuild UP-TO-DATE
        > Task :capacitor-haptics:compileDebugAidl NO-SOURCE
        > Task :capacitor-keyboard:preBuild UP-TO-DATE
        > Task :capacitor-keyboard:preDebugBuild UP-TO-DATE
        > Task :capacitor-keyboard:compileDebugAidl NO-SOURCE
        > Task :capacitor-status-bar:preBuild UP-TO-DATE
        > Task :capacitor-status-bar:preDebugBuild UP-TO-DATE
        > Task :capacitor-status-bar:compileDebugAidl NO-SOURCE
        > Task :app:compileDebugAidl NO-SOURCE
        > Task :capacitor-android:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-app:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-cordova-android-plugins:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-haptics:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-keyboard:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-status-bar:packageDebugRenderscript NO-SOURCE
        > Task :app:compileDebugRenderscript NO-SOURCE
        > Task :app:generateDebugBuildConfig UP-TO-DATE
        > Task :app:javaPreCompileDebug UP-TO-DATE
        > Task :capacitor-android:writeDebugAarMetadata UP-TO-DATE
        > Task :capacitor-app:writeDebugAarMetadata UP-TO-DATE
        > Task :capacitor-haptics:writeDebugAarMetadata UP-TO-DATE
        > Task :capacitor-keyboard:writeDebugAarMetadata UP-TO-DATE
        > Task :capacitor-status-bar:writeDebugAarMetadata UP-TO-DATE
        > Task :app:generateDebugResValues UP-TO-DATE
        > Task :app:generateDebugResources UP-TO-DATE
        > Task :capacitor-cordova-android-plugins:writeDebugAarMetadata
        > Task :app:processDebugGoogleServices FAILED

        Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.  
        Use '--warning-mode all' to show the individual deprecation warnings.
        See
        https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings  
        10 actionable tasks: 2 executed, 8 up-to-date

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':app:processDebugGoogleServices'.
        > No matching client found for package name 'io.ionic.starter'

        * 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 3s

我看到的问题是它引用的 capacitor-cordova-android-plugins 文件夹在每次构建时都会重建,尽管 root build.gradle 和 app build.gradle 已经有了进行了错误中列出的更改。真让我抓狂。

感谢帮助!

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

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