我添加了一个自定义maven存储库以在Android Studio中构建.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')
}
}
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
我在build.gradle里错过了什么?
6条答案
按热度按时间9lowa7mx1#
之后
您应该添加以下内容:
@本杰明解释了原因。
如果您有一个具有身份验证功能的Maven,则可以用途:
秩序很重要。
g52tjvyc2#
您需要在
buildscript
之外定义存储库。buildscript
配置块只为构建脚本的类路径设置存储库和依赖项,而不是为应用程序设置。qqrboqgw3#
Android Studio用户:
如果您想使用grade,请转到http://search.maven.org/并搜索您的maven repo。然后,点击“最新版本”,在左下方的详细信息页面中,您将看到“Gradle”,然后您可以将该链接复制/粘贴到应用的build. gradle中。
6ju8rftf4#
您必须将
repositories
添加到您的构建文件中。对于maven存储库,您必须在存储库名称前面加上maven{}
vdgimpew5#
将maven存储库添加到主
build.gradle
文件的buildscript
配置块之外,如下所示:请确保将它们添加到以下内容之后:
qcuzuvrc6#
这适用于Kotlin DSL(构建版本.gradle.kts):
您还可以在更新版本的Gradle(Gradle 7.4)中将所有子项目的存储库声明集中在 settings.gradle[.kts] 文件中:
请参阅Gradle文档网站中的the full guide here。