Got the problem after updating Android Studio, SDK and tools:
Error:(19, 0) Gradle DSL method not found: 'android()'
Please help to fix it:
Top build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 16
// buildToolsVersion '22.0.1' //23.02.2
}
dependencies {
}
The other one build.gradle (Module:app)file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mateuyabar.android.pillownfc"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
Here is the Error Messages Gradle Sync:
Error:(19, 0) Gradle DSL method not found: 'android()'
Possible causes:
The project 'pillowNFC-master' may be using a version of Gradle that does not contain the method.
-Open Gradle wrapper file
The build file may be missing a Gradle plugin.
-Apply Gradle plugin
Event Log:
11:20:46 Gradle sync started
11:20:48 Gradle sync failed: Gradle DSL method not found: 'android()'
Consult IDE log for more details (Help | Show Log)
I know, this problem was asked before, but I didn't find solution in anothe discussions =(
It would be nice if somebody can help, I'm quite new in programming.
You are using the wrong build.gradle file
In your top-level file you can't use the android block.
Check also this post.
Just remove this part from the first build.gradle
android {
compileSdkVersion 16
// buildToolsVersion '22.0.1' //23.02.2
}
dependencies {
}
Also pay attention.
Since you are using the appcompat v23, you have to compile with API 23.
In your module/build.gradle change the compileSdkVersion to 23
compileSdkVersion 23
Related
I want to add to my app some ads using AdMob, the site says I need to add Google Services to the dependencies to use this functionality. So with Android Studio I went to File->Project Structure->app->Dependencies, I clicked on the "+" button e searched for "play-services". What I found was "com.google.android.gms:play-services:9.4.0" so I added it to the dependencies. During the gradle sync however Android Studio sends some errors and stops the gradle sync.
This is the log I get form the sync: http://pastebin.com/ZpN4RUcm
Here some data that might be useful:
Compile SDK Version: API 17
Build Tools Version: 23.0.1
Android
Studio 2.1.2
This is my main gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
And this is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.serpenssolida.glowdodger"
minSdkVersion 10
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:17.0.0'
compile files('libs/processing-core.jar')
compile project(':facebook')
compile 'com.google.android.gms:play-services:9.4.0'
}
How can I get rid of all the errors?
Change your app gradle file as below and try again:
apply plugin: 'com.android.application'
android {
compileSdkVersion '24'
buildToolsVersion '24.0.2'
...
}
Android Studio is giving this error while compiling the project. I have searched and found that this may happen because of
android
Block in top of the build.gradle.But in my build.gradle it may be not the problem.
here is my gradle files.
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 19
}
dependencies {
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ptrprograms.chromecast"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:mediarouter-v7:19.0.+'
compile 'com.google.android.gms:play-services:6.1.11'
}
You're using Gradle domain-specific language (DSL) defined in the Android plugin before applying that plugin.
Remove the
android {
compileSdkVersion 19
}
in your top-level build.gradle. You already have compileSdkVersion 20 in your app build.gradle file where it actually matters.
now its showing "Error:(16, 0) Gradle DSL method not found: 'runProguard()'
runProguard was renamed to minifyEnabled in the Android Gradle plugin some time ago. You should rename it in your build script as well.
Not Solved:
I'm using gradle-experimental for doing NDK stuff.
Error:(13, 0) Dexcount plugin requires the Android plugin to be configured
MY Top level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
I have android studio 1.1.0 and i just created a new project and i'm trying to import new facebook-sdk 4.0.1 but can not do this, I followed Facebook Getting Started
But can not get it work. My app structure
My build.gradle(Project: MyApplication) file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
//mavenCentral()
}
}
My build.gradle(Module: app) file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.hema.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
}
Finally the error message is:
Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.1
Show in File<br>Show in Project Structure dialog
Edit I added mavenCentral() in the repositories closure in build.gradle(Project: MyApplication) file but not working with same error message.
I solved the problem, It was in my Gradle settings >> Unchecked Offline work
Actually i got the same problem and i solved it ..
1 : File > Import Module ..find facebook-android-sdk-4.0.1 then Finish
2 : Go to File > Project sturucture > dependecies tab > Module Dependencies select :facebook
3 : SYNC project and Rebuild
IF you got error like Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION after rebuilding
go to facebook/build.gradle and change this part
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
to your sdk version like
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
Add mavenCentral() in the repositories closure in your build.gradle file and sync.
Connect your laptop or computer with Internet connection.
It happened with me. I tried everything but at last when I commented laptop with Internet connection it worked.
I did a new install of Android Studio 1.0.2. Getting the following error when opening my first existing android project:
Gradle 'MyApplication' project refresh failed
Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found.
Searched in the following locations: file:/C:/Users/Ntokozo/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
And if I navigate to that searched location I found two jar files which are: support-v4-21.0.3-sources.jar and support-v4-21.0.3-javadoc.jar
Here is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle file under App folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.ntokozo.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Thank you in advance, please bare in mind in responses that I'm a novice and I might not know advanced features.
After re-installing windows OS and a new Android Studio setup the problem disappeared. I don't know what was the problem at first.
Just to start I'm very new to android development/android studio/gradle so forgive me if I'm asking a stupid question.
My team has been working on a project with the beta version of android studio, I've just installed the new version (1.0) and i've imported our project from the github remote repo.
When trying to sync the project with gradle i get the error: Gradle version 2.1 is required. Current version is 2.2.1. It recommends that I change the distributionUrl in gradle-2.1 but when I do I get the error that the gradle plugin requires 2.2.1.
The question is why is my project requiring 2.1 and where can I change this?
Here is my gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.<teamName>.<projectName>"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript{
dependencies{
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
in the gradle-wrapper.properties use the following
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
in build.gradle use
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
also replace
runProguard false
with
minifyEnabled true
I hope this can help
I was having the same issue that you were and had made the exact same updates as described in the Google docs.
The error I was making was editing my app module's build.gradle, and not the project's build.gradle in the root of the project folder for the com.android.tools.build version.
Here's the updated PROJECT's build.gradle file that I'm using that works.
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
compileSdkVersion = 21
buildToolsVersion = "20.0.0"
minSdkVersion = 15
targetSdkVersion = 21
}
allprojects {
repositories {
jcenter()
}
}
To change the gradle distribution used go to this file: {Project folder}/gradle/wrapper/graddle-wrapper.properties.
Then change the distributionUrl to use 2.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip