8

I have a project and I have the apk, but I have changed a value in the calculate.java file and I want to rebuild the project. But the following error appears. What should I do? I am not an android studio developer and I am only a novice. " Could not find com.android.tools.build:gradle:7.0.3. Searched in the following locations:

Azadya79
  • 81
  • 1
  • 1
  • 2
  • 1
    share gradle build file for root if you can . – George Nov 02 '21 at 09:10
  • How can I share "gradle file for root"? – Azadya79 Nov 02 '21 at 15:37
  • @Azadya Post your build.gradle file – JustinW Nov 03 '21 at 09:18
  • @JustInCoding Would u please help me to solve the problem,the followinf file is the build.gradle file. – Azadya79 Nov 03 '21 at 17:52
  • I still cannot view your build file. Paste it using Pastebin or something – JustinW Nov 03 '21 at 18:06
  • @JustInCoding-The file is too log and it can not pasteed here...What is pastebin sir? – Azadya79 Nov 04 '21 at 06:18
  • @JustInCoding-----plugins { id 'com.android.application' } android { compileSdkVersion 30 buildToolsVersion "30.0.3" defaultConfig { applicationId "com.multidev.converter" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } – Azadya79 Nov 04 '21 at 16:53
  • } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.1' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } – Azadya79 Nov 04 '21 at 16:54
  • @JustInCoding---I have added in two file. in the top. – Azadya79 Nov 04 '21 at 16:55

2 Answers2

9

Make sure that your build.gradle file contains Google's Maven repository:

buildscript {
  repositories {
    mavenCentral()
    maven {
      url 'https://maven.google.com/'
      name 'Google'
    }
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:7.0.3'
  }
}

allprojects {
  repositories {
    mavenCentral()
    maven {
      url 'https://maven.google.com/'
      name 'Google'
    }
  }

  ...
}
ackh
  • 1,648
  • 2
  • 18
  • 36
  • 1
    Many ```build.gradle``` files have a shortcut to this code block, see: https://stackoverflow.com/questions/46467561/difference-between-google-and-maven-url-https-maven-google-com – Sam Dec 29 '21 at 16:36
-2

Just Add mavenCentral() to build.gradle

yakup Sintaf
  • 15
  • 1
  • 4
  • 1
    You should give some context to this answer. Why/to what extend does this solve OPs problem? Maybe give an example code of the resulting build.gradle file, and preferably a link to additional info – randmin Jan 22 '22 at 05:32