1

I recently installed Android Studio and when ever I start a new Project no matter what I keep getting this error :

Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.2.0-beta03/gradle-4.2.0-beta03.pom'. Received status code 403 from server: Forbidden
Disable Gradle 'offline mode' and sync project.

and offline mode doesn't work either . I really ran out of ideas . if anyone can help me please do. thanks. this is my build gradle :

    plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        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'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

and this is build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.0-beta03"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

and when I'm clicking on Offline mode this error appears :

A problem occurred configuring root project 'My Application'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:4.2.0-beta03.
     Required by:
         project :
      > No cached version of com.android.tools.build:gradle:4.2.0-beta03 available for offline mode.
      > No cached version of com.android.tools.build:gradle:4.2.0-beta03 available for offline mode.
Possible solution:
 - Disable offline mode and rerun the build
Ali.hsz
  • 11
  • 3

3 Answers3

0

The always working and best solution is to delete the full application with the sdk's if you have any projects take a backup of them and reinstall android studio. That's the most easiest way.

ItsRaptorman
  • 101
  • 8
0

Try to disable gradle offline mode. You can find how to here: How to disable gradle 'offline mode' in android studio?. Then wait for gradle files to sync after restart.

0

Jcenter is no longer available.

You must replace all jcenter()s in you build.gradle with mavenCentral(). Also check your Internet connection(VPN) and proxies because it seems you have problems with your connection.

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78