1

I am new to Android development, but I can not figure out this error for the life of me, I have tried the solution here, and here. I still can not get this app to run.

The error is

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:5:5-19:19 to override.

Here is my build.gradle file

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "n8tivedesigns.com.full_rack_mobile"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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.gms:play-services-maps:17.0.0'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

Any help is very much apperiated.

Gustavo Pagani
  • 6,583
  • 5
  • 40
  • 71
laxer
  • 720
  • 11
  • 41
  • did you added `tools:replace="android:appComponentFactory"` and nothing happened? – Shermano Jun 21 '19 at 17:16
  • I did and it says `The prefix "tools" for attribute "tools:replace" associated with an element type "application" is not bound.` – laxer Jun 21 '19 at 17:17
  • So try my answer below and lets see if it helps – Shermano Jun 21 '19 at 17:23
  • When did this start happening? What did you do? – Martin Marconcini Jun 21 '19 at 17:29
  • @Shermano I added it and took away that error, but added `Error: tools:replace specified at line:6 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 5` – laxer Jun 21 '19 at 17:31
  • @MartinMarconcini It started to happened after I pulled a new fork from our repository. – laxer Jun 21 '19 at 17:31
  • it seems that some library added has androidx dependecies i guess, maybe migrating your project (on Android Studio: `Refactor -> Migrate to AndroidX`) can solve your problem – Shermano Jun 21 '19 at 18:00
  • Whoa, wait, don't refactor to AndroidX without knowing what you're doing lol! That's not a "small version change"; migrating to Android X has a lot of side-effects and consequences that not every project is ready to tackle; and more importantly, not all projects can be migrated by the wizard tool, some dependencies may need further work to proguard certain classes from clashing, etc. I's say, did you know what changed in the fork since the last time you had it working? Does it work in other machines? Is the AS version the same? – Martin Marconcini Jun 21 '19 at 18:10
  • @MartinMarconcini There were 3 class files added and that is about it, It does seem to work on other machines – laxer Jun 21 '19 at 18:14
  • Try removing your support library as some of the modules are conflicting with the Androidx library, you'll probably get many unresolved errors post this then you'll have to resolve the namespace to point to AndroidX – raxerz Jun 22 '19 at 05:06

1 Answers1

0

Add tools:replace="android:appComponentFactory" on application tag in AndroidManifest.xml and also add xmlns:tools="http://schemas.android.com/tools" to your manifest tag

example:

    <?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="(..)">

<application
        android:name=".YourApp"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@drawable/ic_launcher_rounded"
        android:supportsRtl="true"
        tools:replace="android:appComponentFactory"
Shermano
  • 1,100
  • 8
  • 31