【问题标题】:Kotlin in android studioandroid studio 中的 Kotlin
【发布时间】:2017-05-04 06:57:49
【问题描述】:

我从 kotlin 使用,但是当我在我的项目中同步它时,出现以下错误:

Error:Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-3.
Searched in the following locations:
    file:/D:/android-studio/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.pom
    file:/D:/android-studio/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.jar
    https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.pom
    https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.jar
Required by:
    project :

这是我的build.gradle(Module)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "ir.baslam.kotlinme"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
    mavenCentral()
}

这是我的build.gradle(project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-3'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.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 {
        jcenter()
    }
}

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

【问题讨论】:

    标签: android android-studio kotlin


    【解决方案1】:
    ext.kotlin_version = '1.1.2-3'
    

    '1.1.2-3' 版本在 jcenter 存储库中不可用,它在您的文件系统中也不可用。

    当我检查最新版本 1.1.2-2 在 jcenter 中可用时,最新版本是 2017 年 4 月 28 日,所以使用 1.1.2-2 版本而不是 1.1.2-3

    ext.kotlin_version = '1.1.2-2'
    

    【讨论】:

    • @Abhishek Aryan。非常感谢。
    • 请注意:1.1.2-3 现在在回购中。
    • @JoJoRoid kotlin_version 1.1.2-3 现已部署,您可以立即使用。
    • @Abhishek Aryan。非常感谢。
    • ICYMI,ver 1.1.2-3 不再受支持,会报错。使用它,因为现在是 1.1.3。
    【解决方案2】:

    您设置的 Kotlin Gradle 插件版本在存储库中仍然不可用。 尝试设置为任何其他版本,例如:

    ext.kotlin_version = '1.1.1'
    

    【讨论】:

      猜你喜欢
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多