2017-02-10 13 views
0

我与问here有同样的问题。我想申请接受的答案。但我无法这样做,因为IDE表示在该行中:Android Studio中未解决的引用currentThread()。wait()with kotlin

Thread.currentThread().wait(); 

“等待”是一个未解决的参考。我在Android Studio中使用kotlin,所以也许kotlin插件导致问题。在首选项的插件部分说,我已经安装了1.0.6-release-Studio2.2-1 kotlin版本。而在该项目的build.gradle:

buildscript { 
ext.kotlin_version = '1.0.6' 
repositories { 
    jcenter() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:2.2.3' 
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
    classpath "io.realm:realm-gradle-plugin:2.3.0" 

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 

如果我改变kotlin_version是1.0.6释放小Studio2.2-1井指出该Kotlin version that is used for building with Gradle (1.0.6-release-Studio2.2-1) differs from the one bundled into the IDE plugin (1.0.6)

所以我的第一个问题是如何处理未解决的参考错误。 第二:是否有其他/更好的方法来强制IntentService等待,直到DownloadManager完成其下载并调用onReceive(),如问题this中所述。

回答

2

请参阅https://kotlinlang.org/docs/reference/java-interop.html,在页面的中间位置:

有效的Java项目69好心建议喜欢并发实用程序等待()和notify()。因此,这些方法不适用于任何类型的引用。如果你真的需要给他们打电话,你可以投到java.lang.Object(foo as java.lang.Object).wait()

相关问题