Reputation: 437
I'm using Intellij IDEA 2016.3.4 on ubuntu 14.04 LTS to develop android applications. An error- gradle sync failed, missing android extension is occurring.
I'm using sdk platform 25.0.2, kotlin version 1.0.6. This is the line that is throwing an error:
apply plugin: 'kotlin-android'
and the error message is:
Error:(16, 0) Extension with name 'android' does not exist. Currently registered extension names: [ext] Open File
I'm lost. Please can anyone help me out. A detailed solution would be much appreciated!
EDIT 1: Here is the build.gradle code
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'
}
EDIT 2: here is build.gradle root project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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'
}
Upvotes: 1
Views: 960
Reputation: 20140
Add apply plugin: 'android'
in your root build.gradle file.
After that your build.gradle file looks like
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"
}
}
apply plugin: 'android'
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'
}
Upvotes: 1