Android 재질 및 appcompat 매니페스트 합병 실패 to <application> element at AndroidManifest.xml:5:5-19:19

나는 다음 학년이 있습니다

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.material:material:1.0.0-rc01'
}

그러나 앱을 만들고 싶을 때 다음 로그를 얻습니다.

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0-alpha3] 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.

승인! 매니페스트로 이동하여 수행하십시오.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>

</manifest>

그런 다음 Logcat 에이 오류가 발생합니다.

Manifest merger failed with multiple errors, see logs that I have Linked with it



답변

종속성의 첫 번째 및 마지막 줄에서 “rc01″을 “alpha1″로 변경하십시오.


답변

나는 비슷한 문제가 있었다. gradle.properties파일에 두 줄을 추가했습니다 .

android.useAndroidX=true
android.enableJetifier=true

이 두 줄은 Google 파일과 타사 종속성 간의 종속성 충돌을 자동으로 해결했습니다. 다음 링크를 따르십시오 : https://developer.android.com/topic/libraries/support-library/androidx-overview#new-project


답변

Kotlin-KTX 라이브러리를 프로젝트에 추가하려고 할 때도 같은 오류가 발생했습니다.

AndroidX 마이그레이션을 시도하고 문제가 해결되었습니다!

리팩터링 / AndroidX로 마이그레이션


답변

실패 이유

일부인 재료 라이브러리를 사용하고 있습니다. AndroidX의 . AndroidX를 모르는 경우이 답변을 참조하십시오 .

하나의 앱은 AndroidX 또는 이전 Android 지원 라이브러리를 사용해야합니다. 그래서이 문제에 직면했습니다.

예를 들어-

당신의 gradle에서, 당신은 사용하고 있습니다

  • com.android.support:appcompat-v7 (이전 부분 –Android 지원 라이브러리-)
  • com.google.android.material:material(AndroidX의 일부) (AndroidX 빌드 아티팩트 com.android.support:design)

해결책

따라서 해결책은 AndroidX 또는 이전 지원 라이브러리를 사용하는 것입니다. Android는 28.0.0 이후 버전의 지원 라이브러리를 업데이트하지 않으므로 AndroidX를 사용하는 것이 좋습니다. 출시 노트 참조지원 라이브러리의 를 .

AndroidX로 마이그레이션하면됩니다.다음 은 AndroidX로 마이그레이션하는 자세한 답변입니다. 나는 그 대답에서 필요한 단계를 여기에두고 있습니다.

마이그레이션하기 전에 프로젝트를 백업하는 것이 좋습니다.

기존 프로젝트

  • Android Studio> 리 팩터 메뉴> AndroidX로 마이그레이션 …
  • 하단에 Refractor 창이 분석되고 열립니다. 수행 할 변경을 승인하십시오.

영상

새 프로젝트

이 깃발을 당신의 gradle.properties

android.enableJetifier=true
android.useAndroidX=true

동일한 AndroidX 패키지에 대한 @Library 맵핑을 확인하십시오 .

AndroidX로 마이그레이션 @ 공식 페이지 확인

Jetifier 란 무엇입니까?


답변

내 경우에는 이것이 완벽하게 작동합니다. 매니페스트 파일 안에 두 줄 코드 아래를 추가했습니다.

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

신용은 이 답변에 간다 .

매니페스트 파일 예


답변

간단한 솔루션-AndroidX로 마이그레이션

에서 gradle.properties두 스크립트 아래에 추가하십시오.

android.useAndroidX=true
android.enableJetifier=true

이유는 무엇입니까 ↓

AndroidX의 모든 패키지는 문자열 androidx로 시작하는 일관된 네임 스페이스에 있습니다. 지원 라이브러리 패키지는 해당 androidx. * 패키지에 매핑되었습니다. 모든 이전 클래스와 빌드 아티팩트를 새 클래스로 완전히 맵핑하려면 패키지 리팩토링 페이지를 참조하십시오.

참조하시기 바랍니다 패키지 리팩토링 페이지를


답변

android.support 의존성을 제거하십시오.

    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

자재 지침에서 인용

새로운 androidx 및 com.google.android.material 패키지로 아직 전환하지 않으려면 com.android.support:design:28.0.0-alpha3 종속을 통해 Material Components를 사용할 수 있습니다.

참고 : 앱에서 com.android.support와 com.google.android.dependencies를 동시에 사용해서는 안됩니다.

이 의존성을 제거하면 정상적으로 작동합니다.

    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

여기에 완전한 의존성 예제가 있습니다

    dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       implementation 'com.google.android.material:material:1.0.0-beta01'
       implementation 'com.android.support.constraint:constraint-layout:1.1.2'
       testImplementation 'junit:junit:4.12'
       androidTestImplementation 'com.android.support.test:runner:1.0.2'
       androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
   }