Reputation: 41
recently I had some problems with the gradle files so i made few adjustments to solve these problems and every adjustment led to a new error ,the current one is :
Could not find method classpath() for arguments [com.android.tools.build:gradle:4.1.3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
this is the gradle>build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
//classpath "com.android.tools.build:gradle:+"
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is the app>src>build.gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication_10"
minSdkVersion 29
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
//classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
And I changed the gradle version in "gradel-wrapper" file :
#Tue Mar 23 14:02:06 EET 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
the gradle 4.1.3 in the first two files is the default value and I tried to change it to 6.8.2 (as in the gradle-wrapper file) but it throws an error.
Upvotes: 1
Views: 8462
Reputation: 519
Ok I think in your Appgradle file you have called classpath. It should be only added in Gradle file, not in-app Gradle file
dependencies {
//Remove these class path you will be good to go
classpath "com.android.tools.build:gradle:4.1.3"
//classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Upvotes: 1
Reputation: 363429
In your app/build.gradle
remove the classpath
statements
dependencies {
//classpath "com.android.tools.build:gradle:4.1.3"
//classpath 'com.android.tools.build:gradle:+'
//classpath 'com.google.gms:google-services:4.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
...
}
Upvotes: 4