Android Studio Gradle Dsl Method Not Found: 'Android()' -- Error(17,0)

Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)

I went ahead and downloaded the project from the link you provided: http://javapapers.com/android/android-chat-bubble/

Since this is an old tutorial, you simply need to upgrade the software, gradle, the android build tools and plugin.

Make sure you have the latest Gradle and Android Studio:

  • https://www.gradle.org/
  • http://tools.android.com/tech-docs/new-build-system/version-compatibility

build.gradle:

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}

allprojects {
repositories {
jcenter()
}
}

app/build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}

dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
}

Then run gradle:

gradle installDebug

Android Studio Gradle DSL method not found: 'android()' — Error(17,0)

remove this code

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
apply plugin: 'com.android.application'
apply plugin: 'jetty'

from the first build.gradle

Gradle DSL method not found: 'android()' opening project in android studio 1.4

You are using the wrong build.gradle file.

In Android Studio you have a structure like this:

root
|--app
|----build.gradle
|--build.gradle //top level
|--settings.gradle

In the top level file you can't use the android block.

In the top-level file, just use somenthing like this:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}

allprojects {
repositories {
jcenter()
}
}

You have to move the android block inside the app/build.gradle file

apply plugin: 'com.android.application'

android {

compileSdkVersion XX
buildToolsVersion "XX"

defaultConfig {
//
}

}
dependencies {
//
}

How to fix Error:Error:line (23)Gradle DSL method not found: 'android()

delete android settings in project gradle

android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}

if you want to set as common config, you can use is like this:

project gralde:

ext {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}

app gralde:

apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "com.ozuf.poster"
minSdkVersion 16
targetSdkVersion 23
versionCode 5
versionName "0.5 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Android Studio Gradle DSL method not found: 'mavencentral()'

The Facebook SDK page is clear. Add into your project/build.gradle

repositories {
mavenCentral() //note the uppercase C
}

and into your project/app/build.gradle

dependencies { 
compile 'com.facebook.android:facebook-android-sdk:4.+'
}

android studio 1.4.1 Error:(15, 0) Gradle DSL method not found: 'ndk()'

Move the ndk to the defaultConfig scope. Maybe, you'll want to add the sourceSets.main scope too

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.guitarv.www.ndktest"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName = "HelloJNI"
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir "src/main/libs"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Gradle DSL method not found: 'google()'

google() method was only added to RepositoryHandler only in Gradle 4.0. Update your Gradle wrapper to use more recent version:

./gradlew wrapper --gradle-version=4.7 --distribution-type=all

or explicitly set Google's Maven repository, instead of

google()

write

maven { url 'https://maven.google.com' }


Related Topics



Leave a reply



Submit