Error : Could not find method jcenter() for arguments [] on repository container
I
recently updated my android studio from 1.5 to 2.0, but I can’t compile an existing project. When I build the project from the terminal, I get the following error.
gradle builds –stacktrace
alle@alle-Inspiron-3537:~/AndroidStudioProjects/NewsLetter$ gradle build –stacktrace
Note: In order to honor the org.gradle.jvmargs and/or org.gradle.java.home values specified for this build, it is necessary to create a new JVM.
To avoid slowdowns associated with this extra process, you might want to consider running Gradle with daemons enabled.
Please >http://gradle.org/docs/1.4/userguide/gradle_daemon.html Review the User Guide section for the daemon
Failure: The build failed with an exception.
Place:
Build file “/home/alle/AndroidStudioProjects/NewsLetter/build.gradle” line: 5
What went wrong:
There was a problem evaluating the root project “NewsLetter”.
Could not find method jcenter() for arguments [] on repository container.
Try:
Run with the –info or –debug options for more log output.
Build .gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.+'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (application).
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "design.iith.newsletter"
minSdkVersion 16
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'])
testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
Gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Solution
I
know it’s been a month since I’m having the same issue, I just wanted to post my solution.
The console on Android Studio uses your system gradle, which may be an older version. Check it
gradle --version
If the gradle version is lower than 2.0, then you and I have the same problem.
You should upgrade your system gradle
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle-ppa
Install the latest gradle