Search code examples
androidfirebasefirebase-mlkit

Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0]


I am working on the firebase-ml.

Earlier, I am using the 16 version of it and its working fine with my project. But after some requirements, I need to upgrade it to 21.0.0, and then I am facing the

Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:86:5-430:19 to override.

Here is the dependency which I am using

implementation 'com.google.firebase:firebase-ml-vision:21.0.0'

Did anybody resolve this issue?

Additional

import java.text.SimpleDateFormat

buildscript {
    repositories {
        google()
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

buildscript {
    repositories {
        google()
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
    }

    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates
        classpath 'com.android.tools.build:gradle:3.4.1'
        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

repositories {
    google()
    //maven { url 'https://maven.google.com' }
    jcenter()
    mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

repositories {
    maven { url 'https://dl.bintray.com/intercom/intercom-maven' }
}


android {

    lintOptions {
        abortOnError false
    }

    dexOptions {
        jumboMode = true
    }
    signingConfigs {
        config {
            keyAlias 'evalexpert_android_key'
            keyPassword 'algo_driven_eval_expert'
            storeFile file('/Users/nadkyxa/Code/EvalExpert/eval_expert.jks')
            storePassword 'algo_driven_eval_expert'
        }
    }
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId 'xyz.AlgoDriven.EvalExpert'
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 86
        versionName "8.0.4"

        multiDexEnabled true //important

        manifestPlaceholders = [onesignal_app_id: "aa111770-4417-4674-b657-c91e40a3ff25",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]

        externalNativeBuild {
            ndkBuild {
                targets "ocrnative"
                abiFilters "armeabi-v7a"
            }
        }
    }

    useLibrary 'org.apache.http.legacy'

    externalNativeBuild {
        ndkBuild {
            path "src/main/jni/Android.mk"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            externalNativeBuild {
                ndkBuild {
                    arguments "NDK_DEBUG:=1"
                }
            }
        }
    }
    productFlavors {
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
    }
    configurations.all {
        resolutionStrategy {
            force 'androidx.media:media:1.0.0'
        }
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
        //   maven { url 'https://dl.bintray.com/intercom/intercom-maven' }
        maven { url 'https://maven.fabric.io/public' }

        mavenCentral()

        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}
dependencies {
    def suppLibVersion = '28.0.0'

    androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'


    implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
        transitive = true;
    }
    implementation('com.crashlytics.sdk.android:answers:1.3.7@aar') {
        transitive = true;
    }
    implementation project(':UrlImageViewHelper')
    implementation project(':TwoWayGridView')
    implementation project(':SlidingMenu')
    implementation project(':Branch-Invite-SDK')
    implementation('com.google.android.gms:play-services-base:17.0.0') {
        force = true;
    }

    implementation('com.google.android.gms:play-services-maps:17.0.0') {
        force = true;
    }
    // Firebase
    implementation 'com.google.firebase:firebase-core:17.0.0'

    implementation 'com.google.firebase:firebase-perf:18.0.1'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'

    implementation 'com.google.firebase:firebase-ml-vision:21.0.0'
    // OneSignal & Push Notify
    implementation('com.onesignal:OneSignal:3.10.8') {
        exclude group: 'com.google.android.gms'
    }
    implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
    // Intercom
    implementation 'io.intercom.android:intercom-sdk-base:5.+'
    implementation 'io.intercom.android:intercom-sdk-fcm:5.+'
    implementation 'com.android.support:recyclerview-v7:' + suppLibVersion
    implementation 'com.android.support:gridlayout-v7:' + suppLibVersion
    implementation 'com.android.support:support-v4:' + suppLibVersion
    implementation 'com.android.support:design:' + suppLibVersion
    implementation 'uk.co.chrisjenx:calligraphy:2.1.0'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    implementation 'com.koushikdutta.ion:ion:2.+'
    implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    implementation 'com.github.jaydeepw:poly-picker:v1.0.22'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'commons-io:commons-io:2.5'
    implementation 'com.jsibbold:zoomage:1.1.0'
    implementation 'com.wootric:wootric-sdk-android:2.5.2'
    testImplementation 'junit:junit:4.13-beta-3'
    implementation 'io.branch.sdk.android:library:2.+'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'info.hoang8f:android-segmented:1.0.6'
    implementation 'com.otaliastudios:cameraview:1.6.0'
    implementation 'com.github.eventtus:photo-editor-android:v1.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    //    implementation 'com.applozic.communication.uiwidget:mobicomkitui:5.34'
    implementation project(':mobicomkit')
    implementation project(':mobicomkitui')
    implementation project(':mobicommons')
    implementation 'com.google.android.material:material:1.0.0'
}

apply plugin: 'com.google.gms.google-services'

Solution

  • The problem here is that your project is not completely migrated to Android X. There is a conflict in [com.android.support:support-compat:28.0.0] and the androidx.core:core:1.0.0 version.

    Update com.android.support:support libraries to

    implementation "androidx.core:core:1.0.0"
    

    Refer to this guide for More: https://developer.android.com/jetpack/androidx/migrate

    https://developer.android.com/jetpack/androidx

    Update: Try to migrate project to Android X. Attaching the screenshot how to do it. After this invalidate cache and restart. enter image description here