Trying to run my app for the first time but I get this error πŸ˜” [SOLVED]

Hi, I want to run my app on my Android device, which is connected to my laptop via wireless debugging. When I want to run the app I get this error

C:\Users\aquif\Desktop\box\App\essential>npx cap run android
√ Copying web assets from public to android\app\src\main\assets\public in 24.16ms√ Creating capacitor.config.json in android\app\src\main\assets in 2.25ms        
√ copy android in 52.18ms
√ Updating Android plugins in 5.89ms
[info] Found 7 Capacitor plugins for android:
       @capacitor/action-sheet@1.0.3
       @capacitor/app@1.0.3
       @capacitor/device@1.0.3
       @capacitor/dialog@1.0.3
       @capacitor/geolocation@1.1.0
       @capacitor/status-bar@1.0.3
       @capacitor/storage@1.2.0
√ update android in 112.13ms
√ Please choose a target device: » samsung SM-A725F (192.168.100.61:39347)
Γ— Running Gradle build - failed!
[error]
        FAILURE: Build failed with an exception.

        * Where:
        Settings file
        'C:\Users\aquif\Desktop\Aquifer\App\essential\android\settings.gradle'    
        line: 5

        * What went wrong:
        A problem occurred evaluating settings 'android'.
        > Could not open dsl generic class cache for script
        'C:\Users\aquif\Desktop\Aquifer\App\essential\android\capacitor.settings.gradle'
        (C:\Users\aquif\.gradle\caches\7.0\scripts\17sog93krkauhv3euni30iaed).   
        > BUG! exception in phase 'semantic analysis' in source unit
        '_BuildScript_' Unsupported class file major version 61

        * 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 747ms

From the error message, it seems that your settings.gradle might have invalid syntax.

C:\Users\aquif\Desktop\Aquifer\App\essential\android\settings.gradle

What does that file look like?

Looks like this:

include ':app'

include ':capacitor-cordova-android-plugins'

project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')

apply from: 'capacitor.settings.gradle'

Hmm…that is what mine looks like.

This SO post points to a possible Java version issue - flutter - Could not open settings generic class cache for settings file ' - Stack Overflow

Have you tried building directly in Android Studio?

No I have not. But going to try.
By the way, I want live reload, when I use ```
ionic cap run android -l --external



C:\Users\aquif\Desktop\Aquifer\App\essentia>ionic cap run android -l --external

ionic integrations enable capacitor
npm.cmd i --save -E @capacitor/core
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œwin32”,β€œarch”:β€œx64”})

  • @capacitor/core@3.2.4
    updated 1 package and audited 224 packages in 1.749s

16 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

npm.cmd i -D -E @capacitor/cli
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œwin32”,β€œarch”:β€œx64”})

  • @capacitor/cli@3.2.4
    updated 1 package and audited 224 packages in 3.165s

10 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

capacitor.cmd init essentia io.ionic.starter --npm-client npm
error: unknown option β€˜β€“npm-client’
[ERROR] An error occurred while running subprocess capacitor.

    capacitor.cmd init essentia io.ionic.starter --npm-client npm exited with        exit code 1.

    Re-running this command with the --verbose flag may provide more
    information.

C:\Users\aquif\Desktop\Aquifer\App\essentia>

SOLVED. I open my project in Android Studio, and it began building gradle stuff, then it recommended me to upgrade gradle and other stuff, which I did. Now I can run my app with npx cap run android
Thanks.

1 Like