Ale*_*eau 10 android kotlin android-studio android-gradle-plugin android-instant-apps
我一直在努力将新发布的Android Instant Apps与Kotlin编程语言结合起来.在使用以下(标准?)设置创建项目后,当我尝试构建应用程序时,出现错误消息"null无法转换为非null类型com.android.build.gradle.BasePlugin".使用Kotlin可以正常使用标准的"com.android.application"模块; 仅当我尝试在Instant App模块中使用它时才会抛出错误.
顶级build.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"
}
}
// ...
Run Code Online (Sandbox Code Playgroud)
应用模块的build.gradle,在科特林做的工作:
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')
}
Run Code Online (Sandbox Code Playgroud)
基本模块build.gradle,其中Kotlin 不起作用:
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}"
}
Run Code Online (Sandbox Code Playgroud)
instantapp模块build.gradle:
apply plugin: 'com.android.instantapp'
dependencies {
implementation project(':feature')
implementation project(':base')
}
Run Code Online (Sandbox Code Playgroud)
功能模块build.gradle:
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'
}
Run Code Online (Sandbox Code Playgroud)
同样,app模块编译时没有遇到此配置的问题; 另一方面,Android Studio/Gradle给我这个奇怪的"null无法转换为非null类型的com.android.build.gradle.BasePlugin"错误消息,建议重新下载依赖项并同步项目(完成)或重启Android Studio.
Instant Apps是否与Kotlin编程语言实际兼容?我期待着你的答案:)
PS:我使用Android Studio 3.0 Canary 1,从Canary Channel for Build工具安装最新更新等.我的Kotlin插件也应该是最新的.
| 归档时间: |
|
| 查看次数: |
1206 次 |
| 最近记录: |