我已成功配置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的元素中以覆盖。
发布于 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'
}
发布于 2018-09-28 21:02:35
重要更新
在28.0.0
之后,安卓将不会更新支持库。
这将是android.support打包下的最后一个功能版本,鼓励开发人员使用migrate to AndroidX 1.0.0。
所以使用库AndroidX。
androidx
或任何库的稳定版本,因为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'
}
发布于 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">
希望能有所帮助
https://stackoverflow.com/questions/50782435
复制相似问题