79

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
1
  • Please go to this issue and star it. It seems there are a lot of problems because there were a lot of libraries unpublished from jCenter. Dec 11, 2018 at 14:08

11 Answers 11

95

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()
}
3
  • 12
    Downloading the "Android Support Repository" from "Android SDK Manager" definitively solve this issue I got in Android Studio 0.4.3 projects. It remains only a little pity about a deprecation message by Gradle but this is another story so i open this question Feb 1, 2014 at 10:48
  • could you please explain step by step: I mean first download maven-android-sdk-deployer , second what? Jun 12, 2016 at 9:51
  • @H.Aqjn I've rearranged the answer to read a little better (I think), if you're using Gradle you should be fine just to download the support repository from the SDK Manager
    – kassim
    Jun 14, 2016 at 4:55
50

Go to wherever you installed Android Studio (for me it's under C:\Users\username\AppData\Local\Android\android-studio\) and open sdk\tools, then run android.bat. From here, update and download any missing build-tools and make sure you update the Android Support Repository and Android Support Library under Extras. Restart Android Studio after the SDK Manager finishes.

It seems that Android Studio completely ignores any installed Android SDK files and keeps a copy of its own. After running an update, everything compiled successfully for me using compile com.android.support:appcompat-v7:18.0.+

5
  • 8
    This really helped me I expected Android Studio to be using the Android SDK that I had manually installed on my machine. Having the IDE use its own Android SDK instead of using one defined by the developer is really annoying. The SDK should be separate to the IDE.
    – samael
    Oct 19, 2013 at 14:40
  • 13
    I had NO IDEA that Android Studio had its own version of the SDK under AppData. This is super confusing!
    – pqvst
    Oct 25, 2013 at 13:43
  • I had to install Extras/Android Support Library, restart SDK Manager and then Android Support Repository appeared. May 20, 2014 at 12:51
  • This got rid of an error about "com.android.support:appcompat-v7:19.+" for me. Jun 27, 2014 at 13:08
  • Well, I also had similar confusion, when I noticed multiple Android SDK instances on my Ubuntu machine. Hence I had a bad suspicion, that AndroidStudio creates its own instance. Currently I run AS v.2.1.2 and this same issue is still present. I wonder if the team plans to fix it some day soon, or they consider it a feature :)
    – Sold Out
    Sep 22, 2016 at 9:30
27

If you are running on headless CI and are installing the Android SDK through command line, make sure to include the m2repository packages in the --filter argument:

android update sdk --no-ui --filter platform-tools,build-tools-19.0.1,android-19,extra-android-support,extra-android-m2repository,extra-google-m2repository

Update

As of Android SDK Manager rev. 22.6.4 this does not work anymore. Try this instead:

android list sdk --all

You will get a list of all available SDK packages. Look up the numerical values of the components from the first command above ("Google Repository" and others you might be missing).

Install the packages using their numerical values:

android update sdk --no-ui --all --filter <num>

Update #2 (Sept 2017)

With the "new" Android SDK tools that were released earlier this year, the android command is now deprecated, and similar functionality has been moved to a new tool called sdkmanager:

List installed components:

sdkmanager --list

Update installed components:

sdkmanager --update

Install a new component (e.g. build tools version 26.0.0):

sdkmanager 'build-tools;26.0.0'
6
  • Thanks for the nice command line! Unfortunately, now (Android SDK Manager rev. 22.6.4 (from About in GUI)) the response I get to it is: Error: Ignoring unknown package filter 'platform-tools', also for 'android-19' and 'extra-android-support'. Cheers!
    – sdaau
    Jun 7, 2014 at 20:10
  • I´m getting "SWT folder '/opt/android-sdk-linux/tools/lib/arm' does not exist Aug 19, 2014 at 10:23
  • 3
    Thank you for the hint. I've run: android list sdk --all |grep -i repos, it gives me "98-Android Support Repository, revision 6" and "106-Google Repository, revision 11". Then I've installed both packages running android update sdk -u -a -t 98,106 which finally solved the problem (I'm using adt-bundle-linux-x86-20140702.zip, don't know which SDK Manager version it is). Sep 4, 2014 at 10:43
  • 1
    You saved many lives here by mentioning the need of installing Google Repository. Thank you. Nov 26, 2014 at 10:17
  • Yeah mine was also due to missing -- 142- Android Support Repository, revision 21 150- Google Repository, revision 22
    – Bruce Lim
    Oct 5, 2015 at 23:48
5

These dependencies don't exist in Maven Central (see this).

2
compileSdkVersion 17
targetSdkVersion 17

change the compile version from 18 to 17

compile "com.android.support:support-v4:17.0.+"
compile "com.android.support:appcompat-v7:17.0.+"
2

In addition to Kassim's answer:

As Peter says, they won't be in Maven Central

Either use maven-android-sdk-deployer to deploy the libraries to your local repository

Or from Android SDK Manager download the Android Support Repository (in Extras) and an M2 repo of the support libraries will be downloaded to your Android SDK directory

I also had to update the "Local Maven repository for Support Libraries" in Android SDK Manager.

1

to echo @friederbluemle, you can also just launch the SDK manager from the command line if you have the Android SDK tools installed:

$ android

and then in the UI that pops up, select the tools/repositories that need to be installed -- in your case the support library repo

1

Try to turn off your firewall, it works for me. It seems that android studio wants to download some dependencies and our firewall prevents it from downloading it, just be aware that turning your firewall off may lower the security of your computer. If you have more time you can manually allow your android studio to bypass your firewall, this way you can turn on your firewall while allowing android studio to download anything that it wants.

1

I had this message in Android Studio 2.1.1 in the Gradle Build tab. I installed a lot of files from the SDK Manager but it did not help.

I needed to click the next tab "Gradle Sync". There was a link "Install Repository and sync project" which installed the "Android Support Repository".

1
  1. Install android sdk manager
  2. check if building tools installed. install api 23.
  3. from the Android SDK Manager download the 'Android Support Repository'
  4. remove cordova-plugin-android-support-v4
  5. build
0

Add this to your gradle:

allprojects {
    buildscript {
        repositories {
            maven {
                url "https://dl.bintray.com/android/android-tools"
            }
        }
    }
...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.