2014-04-07 16 views
6

Ho provato a rimuovere le librerie jar * e ad aggiungerle come dipendenze maven-repository. Sembra molto promettente, ma non sono in grado di farlo. L'ho provato con una singola libreria (GSON) e ora il mio gradle.build assomiglia a questo:Android/gradle: impossibile utilizzare il repository

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') 
    } 
} 

Ma un semplice sudo gradle build restituisce il seguente errore:

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 

sono collegato ad internet e Sto usando Ubuntu.

risposta

14

tenta di aggiungere:

repositories { 
    mavenCentral() 
} 

sullo stesso livello apply plugin: 'android'.

+0

fantastico! funziona come un fascino :) – NaN

Problemi correlati