应用插件';kotlin android';在即时应用程序中,结果为;null不能强制转换为非null类型com.android.build.gradleBasePlugin";

应用插件';kotlin android';在即时应用程序中,结果为;null不能强制转换为非null类型com.android.build.gradleBasePlugin";,android,android-studio,android-gradle-plugin,kotlin,android-instant-apps,Android,Android Studio,Android Gradle Plugin,Kotlin,Android Instant Apps,我一直在尝试将最新公开发布的Android即时应用程序与Kotlin编程语言相结合。使用以下(标准?)设置创建项目后,当我尝试构建应用程序时,我收到一条错误消息“null不能转换为非null类型com.android.build.gradle.BasePlugin”。使用Kotlin与标准的'com.android.application'模块配合使用效果良好;只有当我尝试在即时应用程序模块中使用它时,才会引发该错误 顶级构建。渐变: buildscript { repositorie

我一直在尝试将最新公开发布的Android即时应用程序与Kotlin编程语言相结合。使用以下(标准?)设置创建项目后,当我尝试构建应用程序时,我收到一条错误消息“null不能转换为非null类型com.android.build.gradle.BasePlugin”。使用Kotlin与标准的'com.android.application'模块配合使用效果良好;只有当我尝试在即时应用程序模块中使用它时,才会引发该错误

顶级构建。渐变

buildscript {

    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:3.0.0-alpha1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4"
    }
}

// ...
apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':feature')
    implementation project(':base')
}
apply plugin: 'com.android.feature'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        // ...
    }
    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'
    })
    implementation project(':base')
    testCompile 'junit:junit:4.12'
}
应用程序模块build.gradle
,Kotlin在其中工作:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // This will work.

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"


    defaultConfig {
        // ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(':feature')
    implementation project(':base')
}
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android' // This won't work.

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    baseFeature true
    defaultConfig {
        // ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    feature project(':tracker')
    compile 'com.android.support:appcompat-v7:25.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    // Kotlin standard library.
    compile "org.jetbrains.kotlin:kotlin-stdlib:${gradleKotlinVersion}"
}
基本模块build.gradle
,其中Kotlin不起作用:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // This will work.

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"


    defaultConfig {
        // ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(':feature')
    implementation project(':base')
}
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android' // This won't work.

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    baseFeature true
    defaultConfig {
        // ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    feature project(':tracker')
    compile 'com.android.support:appcompat-v7:25.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    // Kotlin standard library.
    compile "org.jetbrains.kotlin:kotlin-stdlib:${gradleKotlinVersion}"
}
instantapp模块构建.gradle

buildscript {

    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:3.0.0-alpha1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4"
    }
}

// ...
apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':feature')
    implementation project(':base')
}
apply plugin: 'com.android.feature'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        // ...
    }
    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'
    })
    implementation project(':base')
    testCompile 'junit:junit:4.12'
}
功能模块构建.gradle

buildscript {

    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:3.0.0-alpha1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4"
    }
}

// ...
apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':feature')
    implementation project(':base')
}
apply plugin: 'com.android.feature'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        // ...
    }
    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'
    })
    implementation project(':base')
    testCompile 'junit:junit:4.12'
}
同样,应用程序模块编译时不会出现此配置问题;另一方面,Android Studio/Gradle给我一条奇怪的“null不能转换为非null类型com.Android.build.Gradle.BasePlugin”错误消息,建议重新下载依赖项并同步项目(完成)或重新启动Android Studio

即时应用程序是否与Kotlin编程语言兼容?我期待着你的回答:)

注:我使用安卓Studio 3.0 Canary 1,并从Canary频道为构建工具等安装了最新更新。我的Kotlin插件也应该是最新的。

这在中介绍。请更新您的版本并重试

为了便于参考,我们在此跟踪以前插件版本的问题:

关于,此问题已得到解决。 同时,您可以手动更新到1.1.3 kotlin插件


如果任何问题仍然存在,请报告,他们将重新开放检查。

我不会太担心现在这样做不起作用。由于com.android.build部门的一些异常,我现在甚至无法构建一个普通的应用程序(kotlin也是),因为TransformClasses with DexBuilderForDeBug经常失败。我通过恢复gradle plugin 2.3.2解决了这些问题,但遗憾的是,这样一来,您就失去了高级探查器的支持。您找到解决问题的方法了吗?绝对没有。我已经在谷歌的问题跟踪上订阅了这个问题,我正在等待他们方面对这个问题的更新。