2016-08-21 100 views
1

我曾嘗試一些依賴添加到我的項目,但我kepp收到此錯誤:搖籃DSL錯誤未找到mavenCentral()

Error:(21, 0) Gradle DSL method not found: 'mavenCentral()' 
Possible causes:<ul><li>The project 'My Application' may be using a version of Gradle that does not contain the method. 
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin. 
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li> 

我想盡一切辦法解決它。這裏是我的gradle這個文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     mavenCentral() 

    } 

    mavenCentral() 
    maven { 
     url "http://indooratlas-ltd.bintray.com/mvn-public" 
    } 
} 

,這是另一種:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 
    def apiKey = project.properties['indoorAtlasApiKey'] ?: "api-key-not-set"; 
    def apiSecret = project.properties['indoorAtlasApiSecret'] ?: "api-secret-not-set"; 
    def pubNubPublishKey = project.properties['pubNubPublishKey'] ?: "not-set"; 
    def pubNubSubscribeKey = project.properties['pubNubSubscribeKey'] ?: "not-set"; 

    defaultConfig { 
     applicationId "io.noxel.showroom" 
     minSdkVersion 19 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     resValue "string", "indooratlas_api_key", apiKey 
     resValue "string", "indooratlas_api_secret", apiSecret.replaceAll("%", "\\\\u0025") 
     resValue "string", "pubnub_publish_key", pubNubPublishKey 
     resValue "string", "pubnub_subscribe_key", pubNubSubscribeKey 
    } 
    buildTypes { 
     release { 
      signingConfig signingConfigs.debug 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { 
      debuggable true 
     } 
     lintOptions { 
      abortOnError false 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.indooratlas.android:indooratlas-android-sdk:[email protected]' 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.google.android.gms:play-services:8.4.0' 
    compile 'com.google.maps.android:android-maps-utils:0.3.+' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.2.0' 
    compile 'com.pubnub:pubnub-android:3.7.5' 
    compile 'com.android.support:design:24.0.0-alpha2' 
} 

誰能告訴我該怎麼解決呢?

回答

3

此:

allprojects { 
    repositories { 
     mavenCentral() 

    } 

    mavenCentral() 
    maven { 
     url "http://indooratlas-ltd.bintray.com/mvn-public" 
    } 
} 

必須被更改爲:

allprojects { 
    repositories { 
     mavenCentral() 
     maven { 
      url "http://indooratlas-ltd.bintray.com/mvn-public" 
     } 
    } 
} 
+0

好的謝謝,這解決了這個錯誤,但現在我有這個: – user6485186

+0

錯誤:連接超時:連接。如果您位於HTTP代理後面,請在IDE或Gradle中配置代理設置。 – user6485186

+0

有什麼想法如何解決它? – user6485186

2

不要添加mavenCentral()兩次刪除一個其是repositories標籤之外。

allprojects { 
     repositories { 
     mavenCentral() 
     maven { 
      url "http://indooratlas-ltd.bintray.com/mvn-public" 
      } 
     } 
    } 
相關問題