Gradle sync not working

Facing error on gradle sync.

A problem occurred configuring root project ‘cht-android’.

Could not resolve all dependencies for configuration ‘:classpath’.
Could not load module metadata from .gradle/caches/modules-2/metadata-2.97/descriptors/com.squareup/javawriter/2.5.0/a8be1fe3b3911d3d3425fe720cf42835/descriptor.bi

Hi Rish!

It doesn’t look like a specif problem in the cht-android but more something from Gradle or maybe Android Studio trying to setup the project with Gradle. I would recommend to do the following from the command line:

  1. Close Android Studio if you have it open.
  2. From the command line execute the following commands (at the root folder of the project):
    $ ./gradlew --stop
    $ ./gradlew clean
    $ rm -Rf .gradle/*
    
    These commands will stop any Gradle daemon and clean any cache. Now try to assemble the app with make assemble to see what happens. If it works, try with Android Studio again in case the error started there.
1 Like

Thank you for the reply,
but the ./gradlew clean is failing with the same error
even though I continued the other steps, “make assemble” also failed.
Here is the complete error message:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘cht-android’.

Could not resolve all dependencies for configuration ‘:classpath’.
Could not load module metadata from .gradle/caches/modules-2/metadata-2.97/descriptors/com.squareup/javawriter/2.5.0/a8be1fe3b3911d3d3425fe720cf42835/descriptor.bin

  • 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface

BUILD FAILED in 545ms
Makefile:35: recipe for target ‘assemble’ failed
make: *** [assemble] Error 1

Hi Rish,

There’s a likelihood some of what gradle has cached locally is corrupt. Could you try running this to delete them:

rm -Rf ~/.gradle

The above command assumes you are running a *NIX setup.

1 Like

Stuck at this after cleaning the cache. Other android projects in my system are working fine as is. Can you figure out any other issue using the screenshot?

I’ve followed the following steps locally using a clean checkout:

rm -Rf ~/.gradle
./gradlew clean
./gradlew assemble

and experienced no issues.

From your screenshot, there are hints pointing to corrupt dependencies. Are you able attach a detailed log file?

Hey @RishJ08 what jdk version are you running? I’ve faced issues before with version 16 and downgrading to 11 worked wonders.

I am using jdk 11 only.
This seems to be working.
One of the previous replies had a clean first then rm -Rf,
I think the order is corrected in your reply.
Thanks a lot.