Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams try to sync, I get this error:

Gradle sync failed: Cause: startup failed:
        build file 'C:\Users\user\AndroidStudioProjects\Chiro\build.gradle': 12: all buildscript {} blocks must appear before any plugins {} blocks in the script
        See https://docs.gradle.org/7.2/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
        @ line 12, column 1.
        buildscript{

Instead of putting the builscript at line 12

put it at line 1

Refer this official docs External dependencies for the build script

If you are getting google repo error, try to remove google() under repositories and use mavenCentral()

I have done that, and i am getting this error now: Gradle sync failed: Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle' (41 s 225 ms) – Becky Mar 25, 2022 at 8:08

In addition with Dickens AS Answer, you need to change this configuration in settings.gradle(Project Settings)

Instead of this : repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

you can use this: repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.