2013-12-13 10 views
87

मैं एंड्रॉयड स्टूडियो में build.gradle के लिए एक कस्टम Maven भंडार जोड़ा Maven डेटा संग्रह स्थान जुड़ लेकिन निर्भरताbuild.gradle को

Maven भंडार और निर्भरता

<repository> 
    <id>achartengine</id> 
    <name>Public AChartEngine repository</name> 
    <url>https://repository-achartengine.forge.cloudbees.com/snapshot/</url> 
</repository> 

<dependency> 
    <groupId>org.achartengine</groupId> 
    <artifactId>achartengine</artifactId> 
    <version>1.2.0</version> 
</dependency> 

build.gradle

नहीं मिला की जा रही है
buildscript { 
    repositories { 
     mavenCentral() 
     maven { 
      url "https://repository-achartengine.forge.cloudbees.com/snapshot/" 
     } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.6.+' 
    } 
} 
apply plugin: 'android' 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0' 
} 

android { 
    compileSdkVersion 19 
    buildToolsVersion "19" 

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

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 

त्रुटि संदेश एंड्रॉयड स्टूडियो में:

A problem occurred configuring root project 'My-MobileAndroid'. 
> Failed to notify project evaluation listener. 
> Could not resolve all dependencies for configuration ':_DebugCompile'. 
    > Could not find org.achartengine:achartengine:1.2.0. 
    Required by: 
     :My-MobileAndroid:unspecified 

build.gradle में मुझे क्या याद आ रही है?

उत्तर

72

आपको buildscript के बाहर भंडार को परिभाषित करने की आवश्यकता होगी। buildscript कॉन्फ़िगरेशन ब्लॉक केवल आपकी बिल्ड स्क्रिप्ट के क्लासपाथ के लिए रिपॉजिटरीज़ और निर्भरताओं को सेट करता है लेकिन आपका एप्लिकेशन नहीं।

+0

इसने निर्भरता को हल किया, लेकिन एंड्रॉइड स्टूडियो ने रिपॉजिटरीज़ को फिर से लोड नहीं किया, इसलिए "आयात ओ rg.achartengine.chart *;। " असफल रहा, क्या आप जानते हैं कि रिपॉजिटरीज़ को "रीफ्रेश" कैसे करें? –

+0

बहुत ही महत्वपूर्ण है। इस –

134

बाद

apply plugin: 'com.android.application' 

आप इस जोड़ना चाहिए:

repositories { 
     mavenCentral() 
     maven { 
      url "https://repository-achartengine.forge.cloudbees.com/snapshot/" 
     } 
    } 

@Benjamin कारण की व्याख्या की।

आप प्रमाणीकरण के साथ एक Maven है, तो आप उपयोग कर सकते हैं:

repositories { 
      mavenCentral() 
      maven { 
       credentials { 
        username xxx 
        password xxx 
       } 
       url 'http://mymaven/xxxx/repositories/releases/' 
      } 
} 

यह क्रम महत्वपूर्ण है।

+5

पर 15 मिनट बर्बाद हो गए हम ग्रेडल फ़ाइल में क्लाउडबीस प्रमाणीकरण कैसे जोड़ सकते हैं? – inder

+0

मैं एंड्रॉइड स्टूडियो को कैसे संशोधित कर सकता हूं ताकि मैवेन रिपोजिटरी को डिफ़ॉल्ट रूप से build.gradle में जोड़ा जा सके। मैं इसके बारे में भूल जाता हूं और फिर से खोजना पड़ता हूं कि पुस्तकालय क्यों लोड नहीं हो रहे हैं। – Mike

24

एंड्रॉयड स्टूडियो उपयोगकर्ता:

आप अपने Maven रेपो के लिए खोज, ग्रेड का उपयोग http://search.maven.org/ पर जाने के लिए और चाहते हैं। फिर, "नवीनतम संस्करण" पर क्लिक करें और नीचे बाईं ओर दिए गए विवरण पृष्ठ में आपको "ग्रैडल" दिखाई देगा, जहां आप उस लिंक को अपने ऐप के build.gradle में कॉपी/पेस्ट कर सकते हैं।

enter image description here

+1

आपने मेरा दिन बनाया, बहुत बहुत धन्यवाद। इसके अलावा, यह आधिकारिक ZXing gh पृष्ठ में क्यों नहीं है?यह खोजना इतना मुश्किल नहीं होना चाहिए ... –

2

आप अपने निर्माण फाइल करने के लिए repositories जोड़ने के लिए।

repositories { 
     maven { 
      url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases" 
     } 
    } 

सुनिश्चित करें कि आप उनके पीछे जोड़े हैं: Maven खजाने के लिए आप इस प्रकार अपने मुख्य build.gradle फ़ाइल के buildscript विन्यास ब्लॉक के बाहर Maven भंडार जोड़े maven{}

repositories { 
    maven { url "http://maven.springframework.org/release" } 
    maven { url "http://maven.restlet.org" } 
    mavenCentral() 
} 
3

साथ रिपॉजिटरी नाम उपसर्ग के लिए है निम्नलिखित:

apply plugin: 'com.android.application' 
संबंधित मुद्दे