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

新手上路,请多包涵

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

IDE:3.2 Canary 17 目标 API:28 编译 API: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'
}

构建失败的错误是:

清单合并失败:[androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86 中的属性 application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) 也存在于 [com.android .support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory)。建议:将 ‘tools:replace=“android:appComponentFactory”’ 添加到 AndroidManifest.xml:6:5-40:19 的元素以覆盖。

原文由 Rahul Rastogi 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 502
1 个回答
  1. 转到 gradle.properties

android.useAndroidX=true

android.enableJetifier=true

  1. 改变你的依赖

实施 ‘com.androidx.support:design:28.0.0’

实施 ‘com.androidx.support:design:28.0.0’

原文由 Shoaib Yousuf 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题