当我尝试同步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 s 360 ms)
这是我的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
答案 0 :(得分:0)
尝试一下:
在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(模块)中:
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'
}