Android Studio build.gradle errors

84 Views Asked by At

When I create a new project, I get these errors:

ERROR: Failed to resolve: androidx.appcompat:appcompat:1.6.1 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app

ERROR: Failed to resolve: androidx.core:core-ktx:1.12.0 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app

ERROR: Failed to resolve: com.google.android.gms:play-services-maps:18.2.0 Install Repository and sync project Show in Project Structure dialog Affected Modules: app

ERROR: Failed to resolve: androidx.test:runner:1.5.2 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app

ERROR: Failed to resolve: androidx.test.espresso:espresso-core:3.5.1 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app

Help me to solve them, please ><

Android Studio 3.4.1

I tried to fix the problems using other ppl answers on other similar questions, but it still doesn't work.

I cleared the cache, tried to delete .gradle, tried to add implementation 'androidx.appcompat:appcompat:1.1.0' and implementation "androidx.core:core-ktx:1.1.0", nothing works, unfortunately

1

There are 1 best solutions below

0
Zibran On

Here are some steps you can take to resolve these issues:

  1. Ensure you have the correct repositories in your project-level build.gradle file. The Google Maven repository is required for AndroidX and Google Play Services libraries. Your project-level build.gradle file should look something like this:
allprojects {
    repositories {
        google()
        jcenter()
    }
}
  1. Check your internet connection. Gradle needs to download dependencies from the internet. Make sure your internet connection is working properly and that Android Studio has the necessary permissions to access the internet.

  2. Use the latest versions of the dependencies. Sometimes, the specified versions of the libraries may not be available. You can check the latest versions of the libraries on Maven Repository. Replace the versions in your app-level build.gradle file with the latest ones.

  3. Sync your project with Gradle files. After making changes to the build.gradle files, you need to sync your project. You can do this by clicking on the "Sync Project with Gradle Files" button in the toolbar.

  4. Clean and rebuild your project. Go to Build > Clean Project, and then Build > Rebuild Project.

  5. Update Android Studio. You're using Android Studio 3.4.1, which is quite old. Consider updating to the latest version of Android Studio. Newer versions come with fixes for many issues and better support for AndroidX.

If none of these steps work, please provide more details about your build.gradle files and the exact error messages you're seeing.