首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Gradle项目同步失败,Kotlin

Gradle项目同步失败,Kotlin
EN

Stack Overflow用户
提问于 2017-11-23 13:02:01
回答 8查看 12.6K关注 0票数 3

我使用的是测试版Kotlin和Android-Studio频道。在更新到最新版本后,我得到了一些gradle同步错误。

下面是我从事件日志中复制的日志:

代码语言:javascript
运行
复制
Error:Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0-rc-39.
Searched in the following locations:
    file:/home/yourpc/Android/android/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
    file:/home/yourpc/Android/android/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
    https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
    https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
    https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
    https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
Required by:
    project :

下面是build.gradle

代码语言:javascript
运行
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.0-rc-39'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0-alpha04'
        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:

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.udebest.myapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            postprocessing {
                removeUnusedCode false
                removeUnusedResources false
                obfuscate false
                optimizeCode false
                proguardFile 'proguard-rules.pro'
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

有谁知道这是怎么回事吗?我真的不知道我该如何解决这个问题?我找不到任何解决方案。

EN

回答 8

Stack Overflow用户

发布于 2017-11-25 17:30:53

buildscriptallprojects中的repositories更改为:

代码语言:javascript
运行
复制
{
    google()
    jcenter()
    mavenCentral()
    maven {
        url 'https://dl.bintray.com/kotlin/kotlin-dev/'
    }
}

这对我很有效。

票数 6
EN

Stack Overflow用户

发布于 2018-04-09 06:23:59

首先,我通过工具,Kotlin,配置Kotlin插件更新更新了kotlin插件。

之后,在应用程序目录中的build.Gradle文件搜索中:

代码语言:javascript
运行
复制
repositories {
         // You need to add the following repository to download the
        // new plugin.
        google()
              }

我添加了一个新存储库

代码语言:javascript
运行
复制
maven { url 'C:/Program Files/Android/Android Studio/gradle/m2repository/'}

这是通过资源所在的本地目录的路径。在此之后,请再次尝试同步

票数 1
EN

Stack Overflow用户

发布于 2017-11-23 13:30:32

更改并尝试

代码语言:javascript
运行
复制
classpath 'com.android.tools.build:gradle:3.1.0-alpha04'

代码语言:javascript
运行
复制
classpath 'com.android.tools.build:gradle:3.0.0'

这可能是由于gradle的alpha版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47447877

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档