【问题标题】:AndroidStudio/Kotlin - Unresolved reference: ReadWriteProperty - Kotlin version 1.0.0-beta-1038AndroidStudio/Kotlin - 未解决的参考:ReadWriteProperty - Kotlin 版本 1.0.0-beta-1038
【发布时间】:2015-10-24 23:13:24
【问题描述】:

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

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

未解决的参考:ReadWriteProperty

类名为 PreferenceUtils.kt:

build.grade(模块: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(模块: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
}

如果您需要更多信息,请告诉我。谢谢!

【问题讨论】:

  • 你导入了吗?导入 kotlin.properties.ReadWriteProperty
  • 嗨@JeremyLyman,我已经尝试过了,但它还在导入行中说“未解决的参考”:(

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


【解决方案1】:

解决了!我必须升级 Kotlin 插件 来自安卓工作室。它开始识别“ReadWriteProperty”。

【讨论】:

    猜你喜欢
    • 2018-10-25
    • 1970-01-01
    • 2021-10-29
    • 2018-10-16
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多