添加最新房间时清单合并失败(Android Jetpack)
Manifest merger failed when adding latest Room (Android Jetpack)
我正在尝试将 Android Jetpack Room 添加到 android 项目。
我在应用 gradle 文件中添加了以下内容
def room_version = "2.1.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
这是房间的最新版本。
但是我得到以下构建错误,请帮助!
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
我添加了生命周期、视图模型、导航、工作管理器,但没有任何问题。
添加后
'tools:replace="android:appComponentFactory"
出现以下错误
Manifest merger failed with multiple errors, see logs
我正在使用
- Linux 薄荷 18.3
- Android Studio 3.2.1
如果您在应用级 build.gradle
文件的 "dependencies" 部分使用不兼容的工件,就会发生这种情况。推荐修复:
Refactor
->Migrate to AndroidX...
然后清理并重建项目。
或者,您可以在应用级 build.gradle
文件中替换它:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
有了这个:
implementation 'androidx.core:core:1.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
将这些行添加到 gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
并手动修复代码中未解析的引用。
然后同步项目 -> 清理项目 -> 重建项目。
在 build.gradle 中添加此房间依赖项后出现此错误:
// Room
def room_version = "2.2.0-rc01"
implementation "androidx.room:room-runtime:$room_version"
// For Kotlin use kapt instead of annotationProcessor
annotationProcessor "androidx.room:room-compiler:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
在 Android Studio 中做了:
- 构建 -> 清理项目
- 文件 -> 使缓存无效/重新启动...
- 文件 -> 与文件系统同步
- 文件 -> 与 Gradle 个文件同步项目
- 构建 -> 重建项目
- 构建 -> 制作项目
- 部署
这就完成了工作。
如果问这是 Android Studio 3.3,2018 年 12 月 25 日构建。
我正在尝试将 Android Jetpack Room 添加到 android 项目。
我在应用 gradle 文件中添加了以下内容
def room_version = "2.1.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
这是房间的最新版本。
但是我得到以下构建错误,请帮助!
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
我添加了生命周期、视图模型、导航、工作管理器,但没有任何问题。
添加后
'tools:replace="android:appComponentFactory"
出现以下错误
Manifest merger failed with multiple errors, see logs
我正在使用
- Linux 薄荷 18.3
- Android Studio 3.2.1
如果您在应用级 build.gradle
文件的 "dependencies" 部分使用不兼容的工件,就会发生这种情况。推荐修复:
Refactor
->Migrate to AndroidX...
然后清理并重建项目。
或者,您可以在应用级 build.gradle
文件中替换它:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
有了这个:
implementation 'androidx.core:core:1.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
将这些行添加到 gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
并手动修复代码中未解析的引用。
然后同步项目 -> 清理项目 -> 重建项目。
在 build.gradle 中添加此房间依赖项后出现此错误:
// Room
def room_version = "2.2.0-rc01"
implementation "androidx.room:room-runtime:$room_version"
// For Kotlin use kapt instead of annotationProcessor
annotationProcessor "androidx.room:room-compiler:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
在 Android Studio 中做了:
- 构建 -> 清理项目
- 文件 -> 使缓存无效/重新启动...
- 文件 -> 与文件系统同步
- 文件 -> 与 Gradle 个文件同步项目
- 构建 -> 重建项目
- 构建 -> 制作项目
- 部署
这就完成了工作。 如果问这是 Android Studio 3.3,2018 年 12 月 25 日构建。