Android API 25 CardView不支持的类型

时间:2017-02-17 14:36:33

标签: android xml android-studio android-cardview

我完全被这个困扰了。我正在运行Android Studio 2.2.2,昨天一切都很好。该应用程序在设备上编译并启动,没有任何问题。今天,我明白了......

enter image description here

查看屏幕截图,您可以看到突出显示的区域,表示"错误:不支持的类型' andorid.support.v7.widget.CardView'。

这是我的Gradle

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }

}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
mavenCentral()
}



android {
compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
    applicationId "com.rdvejuicecalculator.and"
    minSdkVersion 14
    targetSdkVersion 25
    versionCode 88
    versionName "6.3.7"

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def file = output.outputFile
            def fileName = file.name.replace(".apk", "-v" + versionName + "-      
   c" + versionCode + ".apk")
            output.outputFile = new File(file.parentFile, fileName)
        }
    }
}
buildTypes {
    debug {
        applicationIdSuffix ".debug"
        versionNameSuffix "-DEBUG"
        //ext.enableCrashlytics = false
        try {
            signingConfig signingConfigs.debug
        } catch (ex) {
        }
        minifyEnabled false
    }
    release {
        try {
            signingConfig signingConfigs.release
        } catch (ex) {
        }
        zipAlignEnabled true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:9'
compile 'com.afollestad.material-dialogs:core:0.9.0.1'
compile 'io.github.kobakei:ratethisapp:1.0.5'
compile 'com.github.paolorotolo:appintro:4.0.0'
compile 'com.android.support:appcompat-v7:25.1.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
    transitive = true;
}
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
compile('com.crashlytics.sdk.android:answers:1.3.8@aar') {
    transitive = true;
}
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.google.android.gms:play-services-drive:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile files('libs/opencsv-3.8.jar')
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
compile 'com.android.support:multidex:1.0.1'
}

这是引用的布局xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.CardView   xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    card_view:cardCornerRadius="4dp">


    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">


        <RelativeLayout
            android:id="@+id/relativeLayout1"
            style="?pageBackground"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="top"
            android:isScrollContainer="true"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="10dp">


     .... Some text views and edit text views ....


        </RelativeLayout>
    </ScrollView>
</android.support.v7.widget.CardView>

到目前为止我所做的是,清理项目,构建项目,重新安装Android Studio。卸载并重新安装API 25和24到14.但我仍然收到此错误,应用程序无法运行。有没有人有任何想法尝试?

1 个答案:

答案 0 :(得分:2)

布局的文件应位于layout目录中。就像是: `RES /布局/大/ fragment_new.xml