首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >API 28 (P)的Android设计支持库不起作用

API 28 (P)的Android设计支持库不起作用
EN

Stack Overflow用户
提问于 2018-06-10 17:47:40
回答 18查看 234K关注 0票数 113

我已成功配置android-P SDK环境。当我尝试使用android设计支持库时,我遇到了项目构建错误。项目配置包括:

集成开发环境: 3.2金丝雀17目标接口: 28编译接口: 28

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.app.navigationpoc"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

    implementation 'com.android.support:design:28.0.0-alpha3'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
}

构建失败的错误是:

核心: value=(androidx.core.app.CoreComponentFactory):1.0.0-alpha3AndroidManifest.xml:22:18-86也出现在com.android.support:support-compat:28.0.0-alpha3 AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).中。

清单合并失败:来自androidx.core的应用程序@appComponentFactory核心属性:1.0.0-alpha3AndroidManifest.xml:22:18-86建议:将'tools:replace="android:appComponentFactory"‘添加到AndroidManifest.xml:6:5-40:19的元素中以覆盖。

EN

回答 18

Stack Overflow用户

发布于 2018-06-11 23:05:10

您可以使用以前的API包版本的工件,也可以使用新的Androidx,但不能同时使用两者。

如果要使用以前的版本,请将您的依赖项替换为

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:design:28.0.0-alpha3'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
}

如果你想使用Androidx:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

    implementation 'com.google.android.material:material:1.0.0-alpha3'
    implementation 'androidx.cardview:cardview:1.0.0-alpha3'
}
票数 96
EN

Stack Overflow用户

发布于 2018-09-28 21:02:35

重要更新

28.0.0之后,安卓将不会更新支持库。

这将是android.support打包下的最后一个功能版本,鼓励开发人员使用migrate to AndroidX 1.0.0

所以使用库AndroidX

  • Don't使用project.
  • Your库模块或依赖项中的 support AndroidXandroidx或任何库的

稳定版本,因为alpha、beta、rc可能存在您不希望随应用程序一起提供的错误。

在你的情况下

dependencies {
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.1'

    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
}
票数 60
EN

Stack Overflow用户

发布于 2018-06-21 17:24:48

添加以下内容:

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

添加到清单应用程序

<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="whateverString">

希望能有所帮助

票数 44
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50782435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档