Search code examples
androidandroid-studiogradleionic-frameworkcapacitor

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


Been having problems with my Ionic/Angular project running on Android. Trying to troubleshoot a with fresh install of Node, Angular, Ionic, Android studio, new project from Ionic (tabs).

Still wont run and I’ve been stuck on it for two days. Am now getting the following error.

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/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
√ 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

The problem I can see is the capacitor-cordova-android-plugins folder that it is referencing is rebuilding on every build, despite root build.gradle AND app build.gradle already having made the changes listed in the error. Really pulling my hair out with this.

Help appreciated!


Solution

  • I'm currently working on an ionic/Angular project and I had the same mistake as you. What I did:

    1. Close Android Studio.
    2. Delete android and ios folder from my project
    3. Make a build (ionic build).
    4. npx cap add ios
    5. npx cap add android
    6. npx cap update
    7. Relaunch Android Studio