0

I just created an empty android project while including the dependencies I need for the project I got an error only when I add com.google.firebase or com.google.android.gms it will generate error below.

/Users/macbookair/Desktop/ANDROID/APPTEST/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 element at AndroidManifest.xml:5:5-21:19 to override.

Please can anyone help me out, I have be trying for very long time to fix this error.

apply plugin: 'com.android.application'
android {
 compileSdkVersion 28
 defaultConfig {
 applicationId "com.fexample.android.appz"
 minSdkVersion 18
 targetSdkVersion 28
 versionCode 2
 versionName "2.0"
 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 }
 buildTypes {
 release {
 minifyEnabled false
 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 }
 }
 compileOptions {
 sourceCompatibility JavaVersion.VERSION_1_8
 targetCompatibility JavaVersion.VERSION_1_8
 }
}
dependencies {
 implementation fileTree(dir: 'libs', include: ['*.jar'])
 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 'org.apache.httpcomponents:httpcore:4.4.10'
 implementation 'com.squareup.okhttp3:okhttp:3.13.1'
 implementation 'com.facebook.android:facebook-login:4.41.0'
 //If I uncomment the below line it will trigger error
 //implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
 //implementation 'com.google.android.gms:play-services-auth:17.0.0'
 //implementation 'com.google.firebase:firebase-core:17.2.0'
 //implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
android {
 useLibrary 'org.apache.http.legacy'
}
apply plugin: 'com.google.gms.google-services'
android { sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/public'] } } }

From the below screenshot this implementation 'com.android.support:appcompat-v7:28.0.0' also has an error but when I build apk it create successfully, I don't think is good.

Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='support-fragment', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.swiperefreshlayout', myArtifactId='swiperefreshlayout', myVersion='1.0.0', myPacking='aar', myClassifier='null'}

enter image description here

asked Sep 18, 2019 at 8:05

1 Answer 1

1

I'll suggest you try one of the following:

1) Migrate the whole project to use the androidx libraries which you can do under Refactor> Migrate to AndroidX from the menu bar.

2) Downgrade the versions of com.google.firebase and com.google.android.gms from 17.x.x to a lower version

answered Sep 18, 2019 at 8:16
Sign up to request clarification or add additional context in comments.

8 Comments

I just tried the downgrade and it worked but the error here implementation 'com.android.support:appcompat-v7:28.0.0' is the there
Awesome, now i'll advise you migrate the whole project to use the androidx libraries like I suggested above
Okay, by doing this migration will it affect supported device? Because am creating this new test project to see why supported device was dropped in my existing project when I upload the apk and to make a clean project too
No, the migration won't affect supported devices.
Sorry that I delayed, implementation 'androidx.appcompat:appcompat:1.0.0' androidTestImplementation 'androidx.test:runner:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' now it worked so should I go ahead and upgrade those to new version?
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.