在我的项目中更新了一些package.json
依赖性之后,我开始看到关于合并的application@appComponentFactory
中AndroidManifest.xml
属性的重复条目的错误:
> Task :app:processReleaseManifest FAILED
/Users/User/Project/android/app/src/main/AndroidManifest.xml:22:18-91 Error:
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:18:5-50:19 to override.
已经尝试在建议中指定的AndroidManifest.xml
上添加条目。可能是哪个依赖性导致的?如何解决冲突?
18 <application
19 android:name=".MainApplication"
20 android:allowBackup="true"
21 android:label="@string/app_name"
22 android:icon="@mipmap/appicon"
23 android:theme="@style/AppTheme"
24 tools:ignore="GoogleAppIndexingWarning"
25 android:usesCleartextTraffic="true">
...
50 </application>
package.json
:
"dependencies": {
"@react-native-community/async-storage": "^1.6.1",
"@react-native-community/blur": "^3.3.1",
"@react-native-mapbox-gl/maps": "^7.0.0-rc2",
"base-64": "^0.1.0",
"i18n-js": "^3.3.0",
"lodash": "^4.17.11",
"lodash.memoize": "^4.1.2",
"moment": "^2.24.0",
"react": "^16.8.3",
"react-native": "^0.59.8",
"react-native-camera": "^3.6.0",
"react-native-device-info": "^2.3.2",
"react-native-firebase": "^5.5.6",
"react-native-fs": "^2.14.1",
"react-native-gesture-handler": "^1.2.1",
"react-native-iap": "^2.5.5",
"react-native-image-resizer": "^1.0.1",
"react-native-in-app-utils": "^6.0.1",
"react-native-iphone-x-helper": "^1.2.0",
"react-native-localize": "^1.1.4",
"react-native-material-dropdown": "^0.11.1",
"react-native-pdf": "^5.1.0",
"react-native-share": "^1.1.3",
"react-native-slider": "^0.11.0",
"react-native-status-bar-height": "^2.4.0",
"react-native-svg": "^9.9.4",
"react-native-svg-uri": "^1.2.3",
"react-native-tts": "^3.0.0",
"react-native-vector-icons": "^6.4.2",
"react-native-webview": "^5.9.1",
"react-navigation": "^3.11.1",
"rn-fetch-blob": "^0.10.16"
},
控制台:
$ ./gradlew assembleRelease -PversionCode=1 -PversionName=1 -PapplicationId='org.application.id'
> Configure project :app
ApplicationId is set to org.application.id
VersionCode is set to 1
VersionName is set to 1
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/User/Project/node_modules/react-native/android
> Configure project :react-native-tts
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/User/Project/node_modules/react-native/android
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /Users/User/Project/android/app/build/generated/assets/react/release/index.android.bundle
info Done writing bundle output
info Copying 32 asset files
info Done copying assets
> Task :app:processReleaseGoogleServices
Parsing json file: /Users/User/Project/android/app/src/release/google-services.json
> Task :app:processReleaseManifest FAILED
/Users/User/Project/android/app/src/main/AndroidManifest.xml:22:18-91 Error:
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:18:5-50:19 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseManifest'.
> 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:18:5-50:19 to override.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 49s
252 actionable tasks: 3 executed, 249 up-to-date
答案 0 :(得分:0)
在清单的<application />
标记内添加这2行
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
这对我有帮助。希望这也可以为您提供帮助。
答案 1 :(得分:0)
您必须在清单文件的<Application/>
下添加以下行:
tools:replace="android:appComponentFactory"
android:appComponentFactory="@string/app_name"
如果您使用的是androidx,还请在gradle.properties
中添加以下行:
android.useAndroidX=true
android.enableJetifier=true