Error in my build.gradle with the clean() method - java

I was messing around with my build.gradle trying to add Google's library into my build.gradle for my project because a random error popped up saying i needed to update my com.google.android.gms to 10.2.0 which gave an error so I tried to input google's maven thing.. anyways here's the code with the error:
// 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'
classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong in the individual module build.gradle files
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
The error is "Could not find method clean() for arguments [{type=c;ass org.gradle.api.tasks.Delete}, build_djvq5gyz4y6fnevmcpa9beri7$_run_closure1$_closer5#cf00d12] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler." and it's for the task clean(type: Delete) { delete rootProject.buildDir } code.
Please help! I don't know what else to do at this point arg!

There are some errors in your script. Check the missing }
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.2'
}
} // <-- missing
And remove the last one after the clean task.

build.gradle with the clean() method
clean(type: Delete) {
delete rootProject.buildDir}
// delete it and again sync with gradle

Related

ERROR: Could not find com.android.tools.build:gradle:3.5.2

ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
Required by:
project :
Open File
ext {
var = '3.5.2'
var1 = '3.5.2'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
we recived this error from my android studio when run my projects
we used online and offline mod but they not worked corectly
This error has confused me
The following code is related to wrapper
ext {
var = '3.5.2'
var1 = '3.5.2'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This problem basically occurs when you are trying to load an old project. The best solution as of my knowledge is to download the links one by one, the project is showing and sync it. Check out the build Gradle files for any outdated dependencies.
Check out if you have
google()
repo in your project. Make sure you find this line in your dependencies.
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
I also had this problem on Linux (ubuntu)
I tried different ways but the problem still didn't work out.
Finally, I remove /home/(user)/.gradle directory and restart Android Studio and this error fixed.
Follow these steps:
Copy paste the below code into Project level build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Clean your project from Build > Clean Project
Rebuild you project from Build > Rebuild Project
Make Project from Build > Make Project
Then, File > Invalidate Caches/Restart

Gradle project refresh failed Error: Cannot find JAR 'kotlin-compiler-embeddable-1.1.3-2.jar'

I created a new project and getting following Gradle Sync error.
Gradle 'ProjectX' project refresh failed Error: Cannot find JAR 'kotlin-compiler-embeddable-1.1.3-2.jar' required by module 'gradle-kotlin-dsl' using classpath or distribution.
I am not using 'Kotlin' and using Android 4.0(IceCreamSandwich). Below is my build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Android : build.gradle problem after add sdk

I've add the SDK to the builder.gradle like this
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But it return an error
ERROR: Could not find method compile() for arguments [com.kontaktio:sdk:3.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please help me to fix it.
You need to move the following block from your project build.gradle:
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
}
to your module build.gradle (usually app module).
your project build.gradle dependencies block must use classpath instead of compile. Your project build.gradle should be something like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please take a look Configure your build for more details.
They change the 'compile' into 'implementation' on latest gradle, so you need to change
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
to
dependencies {
implementation 'com.kontaktio:sdk:3.0.2'
}

Android Studio <Failed to resolve: com.android.support:appcompat-v7:28.0.0>

i can't fix tihs problem Failed to resolve: com.android.support:appcompat-v7:28.0.0
anybody can fix this problem?
My problem
buid.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
First, check your build.gradle(Project), whether it was looking like below or not
Second, check your build.gradle(Module:app), whether it was looking like below or not
Please let me know, whether your issue has been resolved or not

Cant import project in Android studio(Could not find method compile() for arguments)

Sorry for my english. I cant understand why i cant import project to my android studio. I have file build gradle
buildscript {
repositories {
jcenter()
}
dependencies {
compile 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url "https://jitpack.io"
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
but i have error:
Error:(9, 0) Could not find method compile() for arguments
[com.android.tools.build:gradle:2.2.2] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open
File
why its mean?
You are using the wrong build.gradle file.
In your top-level file you can't define an android block.
Just move this part inside the module/build.gradle file.

Categories