I have a medium-sized Kotlin project that uses anko and the kotlin android extensions, specifically the synthetic properties from resource IDs. They have all stopped working with my upgrade to Android Studio 3.0 Canary 1. Though it seems they have also stopped working for AS 2.3.2.
Here is the relevant top-level build script:
buildscript {
ext.kotlin_version = '1.1.2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
And in my app module's build script, the relevant parts are:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
mavenCentral()
jcenter()
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
dataBinding {
enabled = true
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'org.jetbrains.anko:anko-sdk21:0.9.1'
compile 'org.jetbrains.anko:anko-support-v4:0.9.1'
compile 'org.jetbrains.anko:anko-appcompat-v7:0.9.1'
kapt "com.android.databinding:compiler:2.5.0-alpha-preview-02"
}
kapt {
generateStubs = true
}
My command-line build succeeds; in fact the build in the IDE succeeds. But Kotlin gives me red identifiers for all my synthetic property usages now.
One possible clue is that Kotlin doesn't seem to recognize my Activity (an AppCompatActivity) as being a subclass of Context:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MultiDex.install(this)
The "this" is error-underlined, saying that it expected a Context! and got a MainActivity; my MainActivity is defined as:
class MainActivity : AppCompatActivity() {
My Kotlin IDE plugin is 1.1.2-4. I don't know how to revert it to an older version.
I tried re-installing Android Studio 2.3.2 but none of the Kotlin plugins are working there any more either.