我要升级Google库:
build.gradle(应用程序):
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
// Here an error appears.
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation "com.android.support:support-vector-drawable:${supportLibraryVersion}"
implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:support-compat:${supportLibraryVersion}"
// These libraries are updated.
// Google Maps.
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation "com.google.android.gms:play-services-base:17.0.0"
// Firebase.
implementation 'com.google.firebase:firebase-config:18.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
// Multidex.
implementation 'com.android.support:multidex:1.0.3'
}
build.gradle(项目):
buildscript {
ext.compile_sdk_version = 29
ext.min_sdk_version = 16
ext.target_sdk_version = 29
ext.kotlin_version = '1.3.40'
ext.supportLibraryVersion = "28.0.0"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Firebase.
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我在第一个支持库中遇到错误。我没有AndroidX,只有28.0.0。更新任何Google库都会导致此错误(Google Maps或Firebase)。
使用groupId com.android.support和androidx。*的依赖项不能 被合并但被发现 IdeMavenCoordinates {myGroupId ='com.android.support', myArtifactId ='loader',myVersion = '28 .0.0',myPacking ='aar', myClassifier ='null'}和 IdeMavenCoordinates {myGroupId ='androidx.versionedparcelable', myArtifactId ='versionedparcelable',myVersion ='1.0.0', myPacking ='aar',myClassifier ='null'}不兼容的依赖项
检查信息:有一些库或工具的组合, 不兼容的库,或可能导致错误的库。一个这样的 不兼容版本与Android支持版本一起编译 不是最新版本(或特别是版本)的库 低于您的targetSdkVersion)。问题ID:GradleCompatible
我看到了Can I use library that used android support with Androidx projects.,having problem and errors with dependencies,https://github.com/react-native-community/async-storage/issues/128。
编译项目后,我在android:supportsRtl="true"
行的“ Build Output”中收到:
任务:app:processDebugManifest失败
C:\ Users \ ... \ AndroidStudioProjects \ ... \ app \ src \ main \ AndroidManifest.xml:22:18-91错误: 来自[com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91的属性application @ appComponentFactory value =(android.support.v4.app.CoreComponentFactory) 也存在于[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value =(androidx.core.app.CoreComponentFactory)。 建议:在AndroidManifest.xml:15:5-145:19的元素上添加'tools:replace =“ android:appComponentFactory”'以进行覆盖。
当我在AndroidManifest <application>
中添加到tools:replace="android:appComponentFactory"
标签时,我收到另一个错误:
在属性:android:appComponentFactory的第15行指定的工具:替换,但未指定新值
C:\ Users \ ... \ AndroidStudioProjects \ ... \ app \ src \ main \ AndroidManifest.xml错误: 验证失败,正在退出
(如Android X: tools:replace specified at line: for attribute, but no new value specified)。
我应该将应用迁移到AndroidX吗?