我在ubuntu 14.04 LTS上使用Intellij IDEA 2016.3.4開發android應用程序。一個錯誤 - gradle sync failed, missing android extension is occurring.
在intellij中創建android應用程序時,Gradle同步失敗16
我使用sdk平臺25.0.2,kotlin版本1.0.6。這是拋出一個錯誤行:
apply plugin: 'kotlin-android'
和錯誤消息是:
Error:(16, 0) Extension with name 'android' does not exist. Currently registered extension names: [ext] Open File
我迷路了。請任何人都可以幫助我。詳細的解決方案將非常感謝!
編輯1:這裏是的build.gradle代碼
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.gogol.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
}
編輯2:這裏的build.gradle根項目
//頂級構建文件,您可以添加常見的配置選項所有子項目/模塊。
buildscript {
ext.kotlin_version = '1.0.6'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'kotlin-android'
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-annotations:25.1.1'
}
android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileSdkVersion 25
buildToolsVersion '25.0.2'
}
有你在的IntelliJ添加的科特林插件 - 我不知道這是有什麼東西用它做但它是值得一試 –
呀,科特林插件已啓用。我也有最近的版本。 –
你是否在'build.gradle'中應用了插件:'com.android.application''? – CrazyCoder