I'm trying to build my first project with Gradle and I think my gradle files and settings are correct.
I'm using only one module and Support V4 + AppCompatBar libraries.
Project - build.gradle
allprojects { repositories { mavenCentral() } }
Project - settings.gradle
include ':AssignmentTempos21'
Main module - build.gradle
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 8 targetSdkVersion 17 } } dependencies { compile "com.android.support:support-v4:18.0.+" compile "com.android.support:appcompat-v7:18.0.+" }
Console output with -i flag:
MacBook-Air-de-Cesar-2:AssignmentTempos21 menor$ ./gradlew -i clean assemble Starting Build Settings evaluated using settings file '/Users/menor/workspace_android/AssignmentTempos21/settings.gradle'. Projects loaded. Root project using build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle'. Included projects: [root project 'AssignmentTempos21', project ':AssignmentTempos21'] Evaluating root project 'AssignmentTempos21' using build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle'. Compiling build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle' using BuildScriptClasspathScriptTransformer. Compiling build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle' using BuildScriptTransformer. Evaluating project ':AssignmentTempos21' using build file '/Users/menor/workspace_android/AssignmentTempos21/AssignmentTempos21/build.gradle'. Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/] FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':AssignmentTempos21'. > Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration ':AssignmentTempos21:_DebugCompile'. > Could not find any version that matches com.android.support:support-v4:18.0.+. Required by: AssignmentTempos21:AssignmentTempos21:unspecified > Could not find any version that matches com.android.support:appcompat-v7:18.0.+. Required by: AssignmentTempos21:AssignmentTempos21:unspecified * Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. BUILD FAILED Total time: 40.787 secs
This is because of slow internet connection or you haven't configure proxy settings correctly. Gradle needs to download some dependencies , if it cant access the repository it fires this error. All you have to do is check your internet connection and make sure gradle can access the maven repository.
Generally, you can refresh dependencies in your cache with the command line option --refresh-dependencies. You can also delete the cached files under ~/. gradle/caches . With the next build Gradle would attempt to download them again.
Go to File -> Settings. Then uncheck -> Offline work on the right. Click the OK button. Then Rebuild the Project.
As Peter says, they won't be in Maven Central
from the Android SDK Manager download the 'Android Support Repository' and a Maven repo of the support libraries will be downloaded to your Android SDK directory (see 'extras' folder)
to deploy the libraries to your local .m2 repository you can use maven-android-sdk-deployer
2017 edit:
you can now reference the Google online M2 repo
repositories { google() jcenter() }
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