This is what my gradle file looks like http://codeshare.io/RWMpl , its throwing a small error saying:
gradle DSL method not found: 'compile()' .
My 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.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'org.ektorp:org.ektorp:1.4.2'
}
allprojects {
repositories {
jcenter()
}
}
I followed the advice on THIS thread(see the accepted answer) , but i still get the following error:
gradle DSL method not found: 'compile()'.
Why ?
Usually, there is a Project build.gradle and a Module build.gradle.
The screenshot that you shared was of your Module build.gradle.
This error seems to me as, you have an android block in your Project build.gradle file.
Remove android block from Project build.gradle and the app will compile fine..
You using a wrong gradle file. Check for build.gradle(Module:yourmodulename), this is where you have to update.
Related
I am unable to run my app in the android emulator. It was working previously, but something broke it.
Error message:
A problem occurred evaluating root project 'android'.
> Could not find method implementation() for arguments [com.google.android.material:material:1.1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I am running gradle 3.2.1. Here is my build.gradle file's buildscript:
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.2.1'
implementation "com.google.android.material:material:1.1.0"
}
}
That is the top-level gradle file.
Move this line to the dependencies section of the build.gradle file inside the app folder, and also update to latest version:
implementation 'com.google.android.material:material:1.1.0-beta01'
For more info, see here: Why are there two build.gradle files in an Android Studio project?
Write that line in build.gradle(Module:yourAppName.app)file
So I'm new to App Development, and I'm struggling with the Gradle Sync:
Blockquote Error:(10, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'MyApplication' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.3 and sync projectThe project 'MyApplication' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
That is the error message I get.
This is the code I am using
// 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:2.3.3'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
apply plugin: 'project-report'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Please help with a way to fix this,
thanks in advance
Regards
There are two build.gradle files in your Android Studio project. The one that you edited is in the project's root directory. That's not the file you should have put those lines in. The other build.gradle is in your module's directory (e.g., app/). Those four compile lines go in a dependencies closure in that build.gradle file.
This is even mentioned in the comment in the file:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
This sample project (from this book) uses some of those same dependencies. My top-level build.gradle file does not have the compile statements:
// 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:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Instead, they are in the app/build.gradle file:
apply plugin: 'com.android.application'
dependencies {
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
}
}
I want to use Gson and Retrofit to interact with an API. According to the documentations, I add theses lines into the build.gradle of my project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral() //this line
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
compile 'com.google.code.gson:gson:2.7' //this line
compile 'com.squareup.retrofit:retrofit:1.9.0' //this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral() //and this line
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
but I have these errors :
Error:(10, 0) Gradle DSL method not found: 'compile()' Possible
causes:The project 'TempoEDF' may be using a version of the
Android Gradle plug-in that does not contain the method (e.g.
'testCompile' was added in 1.1.0). Upgrade
plugin to version 2.3.3 and sync projectThe project
'TempoEDF' may be using a version of Gradle that does not contain the
method. Open Gradle wrapper
fileThe build file may be missing a Gradle plugin. Apply Gradle plugin
So I used the Gradle plugin like my IDE wants to:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
apply plugin: 'gradle'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit:retrofit:1.9.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
but I have this error :
Error:(10, 0) Plugin with id 'gradle' not found. Open
File
What did I do wrong?
so according to the documentations i add theses lines into the build.gradle of my project
Please note the comments in that file:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
I do not know what "documentations" that you read that told you to put these things in the project-level build.gradle file. Please consider providing links, so that we can get that material fixed.
To get past this problem, remove the changes that you made to this file. Then, add those dependencies to the module's build.gradle file (e.g., app/build.gradle in a typical Android Studio project).
I am facing this issue once I put the dependency of GCM.
Error:(50, 0) Gradle DSL method not found: 'comiple()'
Possible causes:The project 'everybill-codebase' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
This is the build.gradle file of line no 50,
comiple 'com.google.android.gms:play-services-gcm:8.4.0'
I am using these services also from play-service
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
this is the build.gradle file in project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
It would be great to know any solution related with this. Thanks in advance.
Eventually someone is going to close this question, but as the other guys pointed out it's just a typo, use compile() instead of comiple().
I'm trying to add an external library. I've created in a/libs folder under project folder and have the following code in my gradle.build file. But it doesn't sync at all.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.1#aar'
}
The error I'm getting is:
Gradle 'BLE_Client' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'compile()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
You shouldn't add this dependency to the root-level build.gradle file. Add it to your module's build.gradle file instead. The top-level build file is for things that are common to all modules in your project, but it's highly unlikely that you'd want all modules to have the same dependencies, or even to share this one.