首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
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

Stack Overflow用户

发布于 2017-11-23 14:54:29

在build.gradle中使用以下版本的kotlin (项目)

代码语言:javascript
运行
复制
kotlin_version = '1.1.4-3'
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

在build.gradle(模块)中声明kotlin的依赖,如下所示

代码语言:javascript
运行
复制
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
票数 0
EN
查看全部 8 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47447877

复制
相关文章

相似问题

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