如何在 build.gradle 中包含多个存储库?
How to include multiple Repositories in build.gradle?
Android Studio 不允许我构建它。它说找不到 com.mixpanel.blahblahblah。
com.mixpanel.blahblahblah 来自 mavenCentral()
我知道问题是因为它不识别 mavenCentral() 因为它只识别其他回购。我怎样才能同时包含这两者并使该项目正常运行?
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.dilmile.dilmile"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
compile 'com.google.code.findbugs:jsr305:1.3.9'
provided 'org.roboguice:roboblender:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
我认为您应该将 Maven Central 添加到您的构建脚本存储库中。我是这样的,工作没问题:
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
...
}
allprojects {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
}
编辑:我相信您的 gradle 文件应该是
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.dilmile.dilmile"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
compile 'com.google.code.findbugs:jsr305:1.3.9'
provided 'org.roboguice:roboblender:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
从现在开始Android Studio 使用jcenter 而不是maven,您应该通过将mavenCentral 更改为jcenter 来迁移存储库
buildscript {
repositories {
//old
//mavenCentral()
//new
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
...
}
allprojects {
repositories {
//old
//mavenCentral()
//new
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
}
jcenter 比 mavenCentral 更完善也更快
jcenter 将镜像 mavenCentral 存储库,因此如果您遇到 mavenCentral 问题,您可以使用 jcenter。
并尽量避免在声明依赖的版本号时使用+。
也可能是问题
最近写了一个依赖管理工具,可以找出哪些依赖已经过期了,大家可以试试
Android Studio 不允许我构建它。它说找不到 com.mixpanel.blahblahblah。 com.mixpanel.blahblahblah 来自 mavenCentral() 我知道问题是因为它不识别 mavenCentral() 因为它只识别其他回购。我怎样才能同时包含这两者并使该项目正常运行?
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.dilmile.dilmile"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
compile 'com.google.code.findbugs:jsr305:1.3.9'
provided 'org.roboguice:roboblender:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
我认为您应该将 Maven Central 添加到您的构建脚本存储库中。我是这样的,工作没问题:
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
...
}
allprojects {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
}
编辑:我相信您的 gradle 文件应该是
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
maven { url 'http://download.crashlytics.com/maven' }
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.dilmile.dilmile"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
compile 'com.google.code.findbugs:jsr305:1.3.9'
provided 'org.roboguice:roboblender:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
从现在开始Android Studio 使用jcenter 而不是maven,您应该通过将mavenCentral 更改为jcenter 来迁移存储库
buildscript {
repositories {
//old
//mavenCentral()
//new
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
...
}
allprojects {
repositories {
//old
//mavenCentral()
//new
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
}
jcenter 比 mavenCentral 更完善也更快
jcenter 将镜像 mavenCentral 存储库,因此如果您遇到 mavenCentral 问题,您可以使用 jcenter。
并尽量避免在声明依赖的版本号时使用+。 也可能是问题
最近写了一个依赖管理工具,可以找出哪些依赖已经过期了,大家可以试试