Gradle 同步问题:无法获取“kotlin-stdlib-jdk8-1.4.30.pom”

时间:2021-03-24 20:10:21

标签: java android android-studio kotlin gradle

当“Gradle 同步”启动时,我在 Android Studio 中收到以下错误:
无法获取“https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.30/kotlin-stdlib-jdk8-1.4.30.pom”。从服务器收到状态代码 403:禁止 禁用 Gradle 的“离线模式”并同步项目
它下载了几个文件,然后卡在同一个文件中kotlin-stdlib-jdk8-1.4.30.pom 并显示上述错误。
我尝试了多种解决方案,例如 herehere,但没有一个能真正解决问题。
而且由于我只使用 Java,为什么 Android 工作室应该关心 kotlin,我可以做些什么来避免与 Kotlin 打交道?
这是 gradle>build.gradle 文件:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        //classpath "com.android.tools.build:gradle:4.1.3"
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:4.2.0'

    }
}

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

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

这是应用程序>src>build.gradle 文件:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.myapplication_10"
        minSdkVersion 29
        targetSdkVersion 29
        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 {

    classpath 'com.android.tools.build:gradle:+'
    classpath 'com.google.gms:google-services:4.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

1 个答案:

答案 0 :(得分:1)

403 Forbidden 通常意味着您从受美国制裁的国家/地区(例如伊朗)进行连接。尝试清理项目,清除 Gradle 缓存,退出 android studio,连接到 VPN 以更改计算机的 IP,打开 Studio 并同步/运行。此外,Shecan 或 Begzar 等一些服务可能会有所帮助。

相关问题