简体   繁体   中英

Adding additional maven repositories for android build.gradle file is not working

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

allprojects {
    repositories {
        jcenter()
    }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.2"

    defaultConfig {
        applicationId "com.sample.app"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apply plugin: 'maven'
repositories {
    maven {
        url "http://mycompany.com/nexus/content/repositories/mobile/Android/common/rest-api/1.0/"
        artifactUrls "http://mycompany.com/nexus/content/repositories/mobile"
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'Android.myApp:rest-api:1.0'
}

above the build.gradle file. When I execute gradle tasks I'm getting

A problem occurred configuring root project 'app'.

Could not resolve all dependencies for configuration ':_debugCompile'. Could not resolve Android.myApp:rest-api:1.0. Required by: :app:unspecified Target host must not be null, or set in parameters.

confirmed pom files and jar files are present in the maven repo.

Its silly.

maven {
    url 'http:////mycompany.app.com/nexus/content/repositories/mobile'
}

url should contain 4 //// after http. We are using nexus and this fixes the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM