android - 清单合并失败 - android studio 错误
问题描述
我将包的名称更改为“com.xxx.xxx”,Refactor > Rename
并将包的名称和应用程序标识符更改为manifest
和gradle
。同步成功,一切正常。根据说明delevopers.google Getting Started和delevopers.google Intermediate Ads内置在我的应用程序中的广告,之前包含在project structure
AdMob中。使用 gradle 时,尝试在物理级别上运行应用程序让我付出了代价。
Manifest merge error: Attribute application @ appComponentFactory value = (android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml: 22: 18-91
also present in [androidx.core: core: 1.0.0] AndroidManifest.xml: 22: 18-86 value = (androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools: replace = "android: appComponentFactory"' to the <application> element in AndroidManifest.xml: 8: 5-27: 19 to override.
如果您在 gradle 属性中做广告android.useAndroidX = true
,android.enableJetifier = true
那么一切都会变得更糟,因为我的MainActivity.java
extendit 是AppCompatActivity
,它不与上述gradle
属性一起使用(android.useAndroidX = true)
解决方案
这是因为在 gradle 中,您还必须将其更改为 androidX 并检查您的依赖关系
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example1.*appname*"
minSdkVersion 22
targetSdkVersion 28
versionCode 3
versionName "3.0"
**testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"**//check this is their or not
}
有时我们忘记定义 testInstrument runner
推荐阅读
- java - Gluon Mobile 项目不适用于 gradle 6
- java - 如何在使用 Selenium 可单击下一个按钮时一一解析网页?
- firebase - 可以在页面加载时获取新的 Firebase ID 令牌吗?
- android - 验证是否通过 Adwords 安装了 android 应用
- json - 如何使用 Enum 类型的字段执行 Typesafe JSON?
- javascript - 将对象用作 SignalR 的参数
- plotly - 尝试安装 Plotly 时出现 Conda ModuleNotFoundError
- regex - 如何将 GMAIL 正文中的特定字段解析为 google SHEETS
- activemq - ActiveMQ 持有一条保留消息和主题多长时间
- android - Cordova adb:命令失败,退出代码 EACCES