why isn't it searching for it in remote repositories?
after all i have at the top of my gradle script mavenCentral()
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
and:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':lvl-licensing')
testCompile 'junit:junit:4.12'
}
result is:
$ ./gradlew --info build
.
.
.
Creating configuration testReleaseProvided.
Creating configuration testReleaseWearApp.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myapp'.
> Could not resolve all dependencies for configuration ':myapp:_debugUnitTestCompile'.
> Could not find junit:junit:4.12.
Searched in the following locations:
file:/home/myuser/Android/Sdk/extras/android/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/myuser/Android/Sdk/extras/android/m2repository/junit/junit/4.12/junit-4.12.jar
file:/home/myuser/Android/Sdk/extras/google/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/myuser/Android/Sdk/extras/google/m2repository/junit/junit/4.12/junit-4.12.jar
Required by:
myapp-container:myapp:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 7.023 secs
Stopped 0 compiler daemon(s).
At runtime, Gradle will locate the declared dependencies if needed for operating a specific task. The dependencies might need to be downloaded from a remote repository, retrieved from a local directory or requires another project to be built in a multi-project setting. This process is called dependency resolution.
Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.
A module is an isolated piece of the bigger project. In a multi-module project, these modules have their own jobs but work together to form the whole project. Most Android projects only have one module, the app module. The build. gradle (Module: app) file here is in the app folder.
The solution described by @Jas worked for me. But, since I had trouble adjusting build.gradle
, I decided to post an answer with the complete change. This is how my build.gradle
looks like ath the end:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
allprojects {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With