34

我尝试使用版本25.2.0的支持库 ,因此我可以使用CameraKit库。无法在Android Studio中安装存储库和同步项目

我已经拿到了最新的编译工具下载:

enter image description here

和支持库: enter image description here

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

问题: 对于每一个支持-library我得到的问题:

Failed to resolve com.android.support:cardview-v7:25.2.0 

如果我尝试点击安装知识库和同步项目没有任何反应。

enter image description here

我已遵循gradle file,例如,可能是我的错误?

+1

更新支持库也 –

+0

当你点击 “安装库和同步工程”,会发生什么? – CommonsWare

+1

@CommonsWare没什么。当鼠标指针位于链接上时,它会更改为指示存在可点击的链接。点击后没有任何反应。我试过** File - > Infalidate caches/Restart **。不幸的是,这没有帮助 – jublikon

回答

22

使用尝试最新的支持库版本:

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

编辑

使用Google Maven Repository

要将它们添加到您的构建,需要首先在您的顶级build.gradle文件中包含Google的Maven存储库:

项目 - 的build.gradle(不应用程序build.gradle

allprojects { 
    repositories { 
     jcenter() 
     // 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/' 
    } 
} 
+0

我已经应用了你提出的改变并得到了问题:未能解决:com。 android.support:design:25.3.1 – jublikon

+0

依赖是来自官方文档...干净的构建,并确保你连接到互联网 – rafsanahmad007

+0

@ jublikon由于它没有列在你的Android工作室,你需要拉最新的。你有一段时间没有更新。 –

57

此前Android的支持库的依赖关系,从Android SDK中管理器下载。

现在,所有新版本都可以从Google的Maven存储库中获得。 未来所有android库将通过maven.google.com

分发所以,通过将以下代码添加到存储库将生成项目。

repositories { 
    maven { 
     url "https://maven.google.com" 
    } 
} 
38

我不得不将以下内容添加到我的项目级别build.gradle。然后按钮来安装和工作。

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 
+0

我不明白为什么他们不会在新项目中包含此项功能。 – Pztar

+7

,因为谷歌Android团队越来越愚蠢的屁股,总是有这样的更新浪费开发人员时间来解决这个愚蠢的错误。 – winsontan520

4

让苏尔把它放在所有项目下!我的错误是把它放在buildscript下。

DONT DO THAT

buildscript { 
    repositories { 
     jcenter() 
     maven { 
      url 'https://maven.google.com' //dont 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 
     } 
    } 
} 
相关问题