在Android Studio中Kotlin构建失败
错误:
Error:Execution failed for task ':synclib:compileKotlin'. > com.intellij.openapi.fileTypes.LanguageFileType.(Lcom/intellij/lang/Language;)V
synclib
模块的build.gradle
文件:
apply plugin: 'java' apply plugin: 'kotlin' compileJava { sourceCompatibility = 1.7 targetCompatibility = 1.7 } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' // compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.firebase:firebase-client-jvm:2.2.3' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile project(':jamodel') } buildscript { ext.kotlin_version = '1.0.0' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } repositories { mavenCentral() }
如何解决或诊断这个?
这是一个工作配置。 您可以将其调整为您的多项目设置:
/build.gradle
buildscript { ext.kotlin_version = '1.0.4' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() } ext { androidBuildToolsVersion = "23.0.3" androidMinSdkVersion = 16 androidTargetSdkVersion = 23 androidCompileSdkVersion = 23 androidApplicationId = "com.some.example" androidVersionCode = 1 androidVersionName = "1.0" supportVersion = "24.0.0" } }
/app/build.gradle
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion parent.ext.androidCompileSdkVersion buildToolsVersion parent.ext.androidBuildToolsVersion defaultConfig { minSdkVersion parent.ext.androidMinSdkVersion targetSdkVersion parent.ext.androidTargetSdkVersion versionCode parent.ext.androidVersionCode versionName parent.ext.androidVersionName } buildTypes { debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'LICENSE.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } dexOptions { preDexLibraries = false jumboMode = false javaMaxHeapSize "4g" } } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" }
按照这些说明或检查: https : //kotlinlang.org/docs/tutorials/kotlin-android.html
- 选择帮助| 在主菜单上查找操作或按CTRL + Shift + A。
- 搜索这个项目:
- 您将被提示输入
kotlin
版本。
从已安装的版本列表中选择最新版本。
-
现在应该更新应用程序的
build.gradle
文件。 -
最后要做的是
sync the project
。 您可以在提示中按“Sync Now
”,或使用Gradle文件调用同步项目 。
希望它会有所帮助
确保所有的应用程序和库build.gradle
的ext.kotlin_version
等于您安装的Kotlin版本
buildscript { ext.kotlin_version = PROP_KOTLIN_VERSION // 1.1.2-3 // this should equal to your installed Kotlin version //... }
- 执行失败的任务'应用程序:copyDebugAndroidTestKotlinClasses' – Android的Kotlin生成错误
- 如何在OS X上使用Intellij IDEA 15.2从Git repo中构建Android项目
- Android Plugin 2.2.0-alpha1无法与Kotlin编译
- Gradle + JUnit + Android数据绑定
- Android设备版本的React-Native项目没有更新,即使模拟器是
- compileReleaseKotlin失败,java.lang.ClassNotFoundException:com.sun.tools.javac.util.Context
- 错误:执行任务’:app:clean’失败。 无法删除文件
- 无法解决:com.android.support
- Android Studio更新到0.6后,Kotlin问题