2016-07-05 111 views
11

什么版本的支持库我想在我的应用程序添加CardView所以我增加了以下依赖于我的gradle这个安装在我的Android工作室

compile 'com.android.support:cardview-v7:22.2.1'

我意识到的错误时,因为我给出了错误的版本号。在谷歌官方文档考虑看看后,我才知道,Android Support Repository是用来装appcompat库。 enter image description here

正如你可以看到我已经安装的支持库是33版。但是如果我改变我的gradle到版本33它仍然显示错误。

我如何检查我有在Android Studio中的是什么版本AppCompatLibrary的?

编辑:

build.gradle文件

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 
android { 
    compileSdkVersion 22 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.spintum.preexam" 
     minSdkVersion 19 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 
repositories { 
    mavenCentral() 
} 
dependencies { 
    // compile fileTree (dir:'libs',include:'achartengine-*.jar') 
    //compile fileTree('libs/achartengine-1.1.0.jar') 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:percent:22.2.0' 
    compile 'com.android.support:design:22.2.1' 
    compile 'com.android.support:appcompat-v7:22.2.1' 
    compile 'com.android.support:support-v4:22.2.0' 
    compile 'com.android.support:cardview-v7:+' 
    //compile 'com.android.support:recyclerview-v7:22.2.+' 
    compile 'com.google.code.gson:gson:2.3.1' 
    compile 'com.google.android.gms:play-services:8.3.0' 
    compile 'com.google.android.gms:play-services-auth:8.3.0' 
    compile 'com.google.android.gms:play-services-identity:8.3.0' 
    compile 'com.google.android.gms:play-services-plus:8.3.0' 
    compile 'com.google.android.gms:play-services-location:8.3.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.github.markushi:circlebutton:1.1' 
    compile 'com.facebook.android:facebook-android-sdk:4.0.0' 
    compile 'de.hdodenhof:circleimageview:2.1.0' 
    compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:[email protected]' 
} 
+1

33是不正确的......应该是23. https://developer.android.com/topic/libraries/support-library/features.html#v7 –

回答

13

检查您的SDK文件夹,看看哪些是最高的现有数量:

如 B:\ Android的SDK \演员\机器人\ m2repository \ COM \机器人\ SUPPORT \程序兼容性-V7

将有每个已安装的版本的文件夹。在撰写本文时,24是最新版本。

更新:

现在,谷歌使用自己的Maven仓库,这将不再有效。 相反,请检查本网站的可用版本。

https://maven.google.com/

+0

它在我的模拟器(棉花糖)上正常工作,但它崩溃在我的设备(KitKat)..任何想法为什么发生这种情况? – Tyson

+0

你可以在我的gradle文件中找到任何错误.. @ Kuffs – Tyson

+0

Grade控制你的构建。如果你崩溃了,那么问题很可能是你的代码。我会建议你打开一个新问题并发布你的崩溃日志。 – Kuffs

4

这是不是Android的支持库的安装版本。

,应该是在摇篮构建文件的版本应该是多少最高版本对应的

compileSdkVersion

在AppLevel摇篮构建文件(默认情况下它是应用程序模块)。

例子:

如果您正在使用compileSdkVersion 23,那么你应该检查最高23.x.x文件夹下面的目录。

\ YOUR-SDK-PATH \ \临时演员的Android \ m2repository \ COM \机器人\ SUPPORT \ cardview-V7

假设您从23开始次数最多的是23.4.0,那么您应该使用此版本号(23.4.0替代33.0.0)作为您的Gradle构建文件(不是安装了Android支持库的版本)。

这意味着您必须根据您的compileSdkVersion使用Android支持库库。

+0

我检查和我的compileSdkVersion是22和我拥有的最高库是'22.2.1',不幸的是它不工作。任何其他建议? – Tyson

+0

它在我的模拟器(棉花糖)上正常工作,但它在我的设备(KitKat)中崩溃。任何想法为什么发生这种情况? – Tyson

+0

Android Studio是否提供任何错误? – Saini

0

最简单的方法是使用+这意味着您的计算机上最新的一个(API级别),那么您不需要再检查SDK文件夹。例如,

compile 'com.android.support:appcompat-v7:21.+' 
compile 'com.android.support:support-v4:21.+' 

但是,有一个警告void using 21.+ ...."