Повторяющийся атрибут application @ appComponentFactory - PullRequest
0 голосов
/ 25 сентября 2019

После обновления некоторых 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

Ответы [ 2 ]

0 голосов
/ 25 сентября 2019

Вы должны добавить строку ниже в вашем файле манифеста под <Application/>:

tools:replace="android:appComponentFactory"
android:appComponentFactory="@string/app_name"

Также добавьте строки ниже в вашем gradle.properties, если вы используете androidx:

android.useAndroidX=true
android.enableJetifier=true
0 голосов
/ 25 сентября 2019

добавьте эти 2 строки в ваш <application /> тег вашего манифеста

   tools:replace="android:appComponentFactory"
   android:appComponentFactory="whateverString"

, это помогает мне.Надеюсь, это также поможет вам.

...