AndroidStudio / Kotlin - 未解决的参考:ReadWriteProperty - Kotlin版本1.0.0-beta-1038

时间:2015-10-24 23:13:24

标签: android android-studio android-gradle build.gradle kotlin

我有一个在Android Studio中使用Kotlin版本1.0.0-beta-1038的Android项目。

我可以在不同的部分使用Kotlin运行它,它在模拟器中编译和工作但是当我尝试使用ReadWriteProperty时它会给出以下错误消息:

未解析的参考:ReadWriteProperty

Unresolved reference: ReadWriteProperty

名为PreferenceUtils.kt的类:

enter image description here

build.grade(Module:app)

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.droidcba.oculto"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'

    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
    compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'

    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'io.reactivex:rxjava:1.0.14'
}

buildscript {
    ext.kotlin_version = '1.0.0-beta-1038'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    }
}

repositories {
    mavenCentral()
}

build.grade(Module:myProject)

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'

        // 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
}

如果您需要更多信息,请与我们联系。谢谢!

1 个答案:

答案 0 :(得分:3)

  

解决!我必须升级Kotlin插件   来自Android Studio。它开始识别" ReadWriteProperty"。