我正在尝试使用版本25.2.0的支持库,因此我将能够使用CameraKit库。
我有最新的构建工具下载:
我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.sample.myapp"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// Google libraries
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.android.volley:volley:1.0.0'
// Third party libraries
compile 'com.flurgle:camerakit:0.9.17'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
}
问题:对于每个支持库,我都会遇到问题:
Failed to resolve com.android.support:cardview-v7:25.2.0
如果我尝试单击安装存储库和同步项目没有任何反应。
我跟着那个gradle file作为例子。可能是我的错?
尝试使用最新的支持库版本:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-vision:10.2.1'
compile 'com.android.volley:volley:1.0.0'
// Third party libraries
compile 'com.flurgle:camerakit:0.9.17'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
这里是细节Dependencies
编辑
要将它们添加到您的构建中,您需要首先在顶级build.gradle文件中包含Google的Maven存储库:
Project - build.gradle(不是app build.gradle
)
allprojects {
repositories {
// If you're using a version of Gradle lower than 4.1, you must instead use:
maven {
url 'https://maven.google.com'
}
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
jcenter()
}
}
以前,Android支持库依赖项是从Android SDK Manager下载的。
现在,所有新版本都可以从Google的Maven存储库中获得。将来所有的android库都将通过maven.google.com
发布
因此,通过将以下代码添加到存储库将构建项目。
repositories {
maven {
url "https://maven.google.com"
}
}
我必须将以下内容添加到我的项目级build.gradle中。然后按钮安装和工作。
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
}
一定要把它放在allprojects
下!我的错误是把它放在buildscript
下面。
不要这样做:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com' //don't put it here
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
但是不要这样做:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com' //put it here
}
}
}