【问题标题】:Facing issue in Latest Support Library v26.0.0-beta1最新支持库 v26.0.0-beta1 中面临的问题
【发布时间】:2017-06-02 10:33:14
【问题描述】:

我在最新支持库中遇到了奇怪的问题。 我刚刚将我的项目迁移到 GOOGLE 提供的最新支持版本并按照谷歌指南

所以问题是在最新的支持文件中找不到 cardView。有人遇到这个问题吗?

这是我的 App Gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-O'
    buildToolsVersion "26.0.0-rc2"
    defaultConfig {
        applicationId "com.temp"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
    lintOptions {
        disable 'RestrictedApi'
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:$support_libs"
    compile "com.android.support:design:$support_libs"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    compile 'jp.wasabeef:blurry:2.1.1'
}

// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
    maven {
        url 'https://maven.google.com'
        // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

这里是项目的gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.support_libs = '26.0.0-beta1'
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

  • 请阅读投票者的问题...您是否尝试过迁移您的项目..

标签: android android-studio gradle


【解决方案1】:

我没有看到 cardview 添加到您的应用程序 gradle 文件中的任何位置的依赖项中。尝试添加:

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

【讨论】:

  • 但我使用 ext.support_libs = '26.0.0-beta1' 版本作为支持库,并且根据谷歌文档 Appcompat 已经包含 cardview,因此无需为 cardview 添加额外的库。较低版本工作正常。但我在 Android O 迁移中遇到了这个问题
【解决方案2】:

AppCompat v7 不包含 CardView,您需要在依赖项中明确声明该库。

所以,将compile 'com.android.support:cardview-v7:$support_libs' 添加到您的依赖项中。

【讨论】:

    【解决方案3】:

    在 gradle 文件中添加这些依赖项:

    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    

    【讨论】:

    • 但我使用 ext.support_libs = '26.0.0-beta1' 版本作为支持库,并且根据谷歌文档 Appcompat 已经包含 cardview,因此无需为 cardview 添加额外的库。较低版本工作正常。但我在 Android O 迁移中遇到了这个问题
    猜你喜欢
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    相关资源
    最近更新 更多