Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android/gradle: not able to use repository

I tried to remove my jar* libraries and add them as maven-repository-dependencies. It looks very promising, but I am not able to do it. I tested it with a single library (gson) and now my gradle.build looks like this:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.code.gson:gson:2.2.4'
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.0"

    defaultConfig {
    minSdkVersion 10
    targetSdkVersion 18
}

sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

But a simple sudo gradle build returns the following error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':_DebugCompile'.
      > Could not find com.google.code.gson:gson:2.2.4.
        Required by:
            :android:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with 
--info or --debug option to get more log output.

BUILD FAILED

Total time: 3.541 secs

I am connected to the internet and I am using ubuntu.

like image 919
NaN Avatar asked Apr 07 '14 12:04

NaN


People also ask

Is there a Gradle repository?

There is no such thing as a Gradle repository. While Maven is the name for both a build tool and a repository type, Gradle ist just a build tool.


1 Answers

Try to add:

repositories {
    mavenCentral()
}

on the same level as apply plugin: 'android'.

like image 196
Ziem Avatar answered Oct 11 '22 18:10

Ziem