对属性android:appComponentFactory在行19处指定的tools:replace,但未指定新值app主清单

时间:2019-01-16 19:20:34

标签: java android sdk

我正在尝试编译一个6个月的代码,但出现此错误:

tools:replace specified at line:19 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 18 Error: Validation failed, exiting app main manifest (this file)

为解决此问题,我在AndroidManifest.xml

中添加了以下行
tools:replace="android:appComponentFactory"

但是现在我得到了这个错误:

Manifest merger failed with multiple errors, see logs

当我搜索此错误时,它要求我从第一步中添加的AndroidManifest.xml中删除该行。因此,这是一个循环。我该如何摆脱这个问题。

我的依赖项:

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/apache-mime4j-0.6 2.jar')
implementation files('libs/httpmime-4.0.1 .jar')
// this line must be included to integrate with Firebase
implementation 'com.hbb20:ccp:2.0.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
implementation 'com.github.mukeshsolanki:country-picker-android:1.1.9'
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.google.android.gms:play-services:10.2.1'
implementation 'com.google.maps.android:android-maps-utils:0.4'
implementation 'com.google.android.gms:play-services-location:10.2.1'
implementation 'com.google.code.gson:gson:2.4'
implementation 'com.airbnb.android:airmapview:1.3.0'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.github.jd-alexander:library:1.1.0'
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-maps:10.2.1'
implementation 'com.google.android.gms:play-services-wallet:10.2.1'
implementation 'com.stripe:stripe-android:4.1.5'
implementation 'com.stripe:stripe-java:1.47.0'
implementation 'com.squareup.picasso:picasso:2.4.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.google.firebase:firebase-core:10.2.1'
implementation 'com.google.firebase:firebase-messaging:10.2.1'
implementation 'com.google.firebase:firebase-database:10.2.1'
implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
testImplementation 'junit:junit:4.12'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

}

1 个答案:

答案 0 :(得分:1)

似乎您的项目中的另一个清单文件存在合并问题。许多元素名称可以在清单中出现多次,例如多个<uses-permission>元素。其中许多标识符通常是android:name,用于将标识符与下一个标识符区分开。通常,如果两个清单源都贡献相同的元素(即,相同的元素名称,相同的android:name值),则这两个元素本身将合并,这意味着:

  • 其中一个属性,而不是另一个属性都将添加到组合元素中。
  • 两者中任何一个属性值都不相同的属性都将导致合并冲突编译错误,除非通过标记指定了分辨率
  • 应用相同的规则合并所有子元素(例如)。

有时,默认的合并规则将无法使您满意。特别是,当存在冲突时,构建将失败,并且可能不是期望的结果。 要声明发生冲突时谁获胜,可以在清单元素中使用tools:* attributes。具体来说:

  • tools:node指示如何解决此特定XML元素的两个版本之间的冲突(例如,针对同一android:name的)
  • tools:replace表示清单的较低优先级版本中的某些属性应被清单的较高优先级版本中的某些替换值覆盖
  • tools:remove表示清单中优先级较低的版本中的某些属性应完全删除

其中每一个都位于工具名称空间中,如果根元素尚不存在,则要求您在根元素上拥有xmlns:tools="http://schemas.android.com/tools"。这些属性仅影响构建工具,对运行时没有任何影响,除了构建工具如何基于工具属性构建应用程序以外。