добавьте репозиторий maven для сборки.Gradle в

я добавил пользовательский репозиторий maven для сборки.gradle в Android Studio, но зависимость не найдена

репозиторий 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>

построить.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')
    }
}

сообщение об ошибке в Android Studio:

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

чего мне не хватает в сборке.Gradle в?

5 ответов


вам нужно будет определить репозиторий за пределами buildscript. The buildscript configuration block устанавливает только репозитории и зависимости для пути к классам вашего скрипта сборки, но не вашего приложения.


после

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

важно порядок.


Пользователи Android Studio:

Если вы хотите использовать grade, перейдите вhttp://search.maven.org/ и поиск вашего Maven РЕПО. Затем нажмите "последняя версия", и на странице сведений в левом нижнем углу вы увидите" Gradle", где вы можете скопировать/вставить эту ссылку в сборку вашего приложения.градля.

enter image description here


добавьте репозиторий maven вне buildscript блок конфигурации вашего main следующим образом:

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

убедитесь, что вы добавляете их после следующего:

apply plugin: 'com.android.application'

вы должны добавить repositories в файле build. Для репозиториев maven вы должны префиксировать имя репозитория с maven{}

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