【问题标题】:Problem with Grade sync in Android StudioAndroid Studio 中的成绩同步问题
【发布时间】:2020-06-26 02:52:10
【问题描述】:

当我尝试同步 grade 时,我收到以下消息:

1:09 PM Gradle 同步失败:找不到 com.android.tools.build:gradle:3.6.1。 在以下位置搜索: - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar 要求: 项目 : 查看 IDE 日志了解更多详情(帮助 | 显示日志)(24 秒 360 毫秒)

这是我的 build.gradle 文件

buildscript {

    repositories {
        google()
        jcenter()

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

而且,我的gradle-wrapper.properties 文件如下:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

【问题讨论】:

    标签: android android-studio gradle


    【解决方案1】:

    试试这个:

    在 build.gradle(Project) 中:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        ext.kotlin_version = '1.3.61'
        repositories {
            google()
            jcenter()
    
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.6.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            // 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
    }
    

    在 build.gradle(Module) 中:

    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.3"
        defaultConfig {
            applicationId "com.example.mytestapplication"
            minSdkVersion 15
            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'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.android.material:material:1.1.0'
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        implementation 'androidx.core:core:1.3.0-alpha02'
        implementation 'androidx.mediarouter:mediarouter:1.1.0'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-10
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2016-06-28
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多