0

Error screenShot

`plugins { id 'com.android.application' }

android { compileSdk 31

defaultConfig {
    applicationId "com.example.helloworld"
    minSdk 16
    targetSdk 31
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}`

The Above code is my build. Gradle

The Version of Android Studio --> Android Studio Bumblebee | 2021.1.1 Patch 2 for Windows 64-bit I am Facing this Gradle build error since morning I had tried all the things Including once from Previous Stack Overflow Users who said still I am stuck Please Help every Advice will we consider as a blessing please Help

I had tried everything from the following posts but sadly Nothing works:

Android Studio 3.0.1 Error: Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

https://www.youtube.com/watch?v=U8YXxZXlcMY

https://www.youtube.com/watch?v=1_vVIi_AOew

https://www.youtube.com/watch?v=h90Y_KMk1Z4

Dev
  • 1
  • 4
  • 1
    Please provide the error log. – Bikram Kumar Apr 03 '22 at 11:00
  • The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip' does not exist. – Dev Apr 03 '22 at 14:43
  • You should connect to the internet and open your project again. It will download that distribution and save it locally. – Bikram Kumar Apr 03 '22 at 15:06
  • I am already connected to internet From the starting – Dev Apr 04 '22 at 05:21
  • Can you check if you have that version in your home directory `~/.gradle/` – Bikram Kumar Apr 04 '22 at 05:30
  • can you please provide the steps to check if I have that version in my home directory ~/.gradle/ – Dev Apr 04 '22 at 05:58
  • Just open the terminal and enter `cd ~/.gradle/`. And then enter `ls -a` if on linux or `dir` if on windows cmd. Check if there is a folder named '7.2'. If on windows change the slashes in path name to backward slashes ( \ ), otherwise it will give error – Bikram Kumar Apr 04 '22 at 06:02
  • In windows powerShell Right !!!! – Dev Apr 04 '22 at 06:34
  • Yes you can also use that. Open it and enter `cd ~\.gradle\ ` and then `ls` or `dir` (both works in powershell). Check for `7.2` folder – Bikram Kumar Apr 04 '22 at 06:52
  • You should also look at `~\.gradle\wrapper\dists\ ` for `gradle-7.2.bin` folder, if you don't find in the home directory. – Bikram Kumar Apr 04 '22 at 07:25
  • In ~\.gradle\ I dont find any folder related to 7.2 so something but I found Something --> 852 gradle.properties – Dev Apr 04 '22 at 07:52
  • in ~\.gradle\wrapper\dists\ I found only gradle-7.2-bin Now what to do – Dev Apr 04 '22 at 07:52
  • It means that gradle-7.2 exists. See if there are other errors. And if possible, please provide the full error log (screenshot would be better). – Bikram Kumar Apr 04 '22 at 08:29
  • `Could not resolve all files for configuration ':app:androidApis'. Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}. Execution failed for MockableJarTransform: C:\Users\DEV\AppData\Local\Android\Sdk\platforms\android-31\android.jar. Cannot create mockable android.jar C:\Users\DEV\AppData\Local\Android\Sdk\platforms\android-31\android.jar ` – Dev Apr 15 '22 at 15:02
  • Please provide a screenshot of the error. – Bikram Kumar Apr 16 '22 at 03:24
  • Provided the error screenshot in the question part You can refer that there – Dev Apr 16 '22 at 05:10
  • What I suspect is, it is not problem with the gradle binary. It could not download some files. Did you try to create a new project and build that? Does it show the same error? Make sure you don't disconnect the network while creating a new project. – Bikram Kumar Apr 16 '22 at 06:24
  • The error screen is the same no matter what so ever project I create or open – Dev Apr 16 '22 at 15:29
  • It looks like you will have to do more. Try [building the app from command line](https://developer.android.com/studio/build/building-cmdline), `cd` to the project root folder and run `gradlew assembleDebug`. Then show me the error. – Bikram Kumar Apr 17 '22 at 03:43

1 Answers1

0

Go to File -> Project Structure -> Project

Now make Android Gradle Plugin Version as 7.1.2

Gradle Version as 7.2

Update any other dependencies you are using also do Invalidate Caches and Restart.

oyeraghib
  • 878
  • 3
  • 8
  • 26
  • It is already that by default .......... – Dev Apr 03 '22 at 14:44
  • can you show your build.gradle once – oyeraghib Apr 03 '22 at 17:15
  • plugins { id 'com.android.application' } android { compileSdk 31 defaultConfig { applicationId "com.example.helloworld" minSdk 16 targetSdk 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } – Dev Apr 04 '22 at 05:22
  • compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } – Dev Apr 04 '22 at 05:22
  • Also provided the build.gradle in the Question part You can refer that – Dev Apr 04 '22 at 05:26