I'm trying to add AdMob to my app. I added the line below to build.gradle
implementation 'com.google.android.gms:play-services-ads:18.2.0'
However, after syncing, I started to get the error below:
ERROR: 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 element at AndroidManifest.xml:6:5-28:19 to override."
What should i do?
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.bartech.myapp"
minSdkVersion 21
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 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
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.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
}
AndroidManifest.xml
<?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="com.bartech.myapp">
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.bartech.myapp.quiz1"/>
<activity android:name="com.bartech.myapp.summary"/>
<activity android:name="com.bartech.myapp.info"/>
</application>
</manifest>
Problem is happening because you are using Support Libraries such as support:appcompat, support:support-v4 along with the latest version of the play-services-ads (18.2.0) which already migrated to AndroidX.
So, you are getting this error because your app is using Support Library but play-services-ads is already using AndroidX.
In order to fix:
1) Migrate your app to AndroidX (recommended). More info HERE
2) Use an old version of play-services-ads (such as 'com.google.android.gms:play-services-ads:16.0.0' for example.)
This second option may fix your issue because play-services-ads:16.0.0 was still using Support Library as well.
Related
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.
How fix this error..
gradel file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.niks.abc"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Don't forget to add
android.useAndroidX=true
android.enableJetifier=true
to your gradle.properties. I always forget this when I get on a new machine because gradle.properties is not in source control. Would be great if we got a sensible error in this case.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.niks.abc">
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Hope this will help you enough.
On including implementation 'com.google.firebase:firebase-core:17.0.0'
in my build.gradle(app) my project does not successfully sync.
i've tried cleaning up the project i've tried ,as the error suggests, increasing minSdkVersion to 16 (it gives another error) but nothing worked.
build.gradle(app)
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.saad.error"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:17.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'
}
apply plugin: 'com.google.gms.google-services'
Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.saad.error">
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I just started developing on Android and got that same error. I changed my minSdkVersion from 15 to 16, and then it built and ran.
I'm not an expert but I had the same problem just now and I went to the app folder in android mode right-clicked it and entered 'open module settings'.In the 'default config' I set the minSDK to the versions I have installed
Got the same problem just fix it by migrating the project to androidx
Click on the Refactor tab->Migrate to androidx->Just give a backup directory->click again Refactor
Hope this will clear the same
So I have an issue with my compile code. I changed everything the right way to implementation but I still keep on getting this error.
I have tried to change the Version and the compile to API but I don't understand what still goes wrong.
Warning = PICTURE
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.gebruiker.GIPAPP"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
api 'com.google.firebase:firebase-core:15.0.0'
api 'com.google.firebase:firebase-auth:15.0.0'
api 'com.google.firebase:firebase-database:15.0.0'
api 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
Check option one here (to add firebase). The firebase dependencies are implementation... https://firebase.google.com/docs/android/setup
Probably you put another thing and gradle changed it to api automatically, what is not ok. So, change the api words to implementation
The error/warning I get now is the next after changing some versions. Changed it all to the latest versions.
package="com.example.gebruiker.gipapp">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
<activity android:name=".RegistrationActivity"></activity>
<activity android:name=".PasswordActivity"></activity>
<activity android:name=".ProfileActivity"></activity>
<activity android:name=".UpdateProfile"></activity>
<activity android:name=".UpdatePassword"></activity>
<activity android:name=".ActivityProfile"></activity>
</application>
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 element at AndroidManifest.xml:8:5-29:19 to override.
When i add to this line implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+' in my dependency
it cause error
* my error *
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:8:5-25:19 to override.
And
implementation 'com.android.support:appcompat-v7:28.0.0'
this line become red line
I think the problem is reason of version
How can I avoid that clash?
I already try to change version and add code in manifest
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<usespermissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
but it didn't work
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.blogapp">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
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">
<activity android:name=".Activities.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.RegisterActivity" />
<activity android:name=".Activities.PostActivity" />
<activity android:name=".Activities.HomeActivity" />
</application>
</manifest>
This is my dependency
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.blogapp"
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 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation "com.wdullaer:materialdatetimepicker:3.6.4"
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
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.android.support:design:28.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.github.siyamed:android-shape-imageview:0.9.3#aar'
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
apply plugin: 'com.google.gms.google-services'
I hope use this imageCropper no trouble in my dependency
https://github.com/ArthurHub/Android-Image-Cropper
The library has moved to a new one (old one not maintained)
https://github.com/CanHub/Android-Image-Cropper
Read here
Use version 2.7.0
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
version 2.8.0 uses androidx support libraries , so use it only if you use androidx support libraries in your project
Change log
2.8.0
Fix crash on Android O (thx #juliooa)
Update to support library to AndroidX (thx #mradzinski)
Handle failure when selecting non image file (thx #uncledoc)
More translations (thx #jkwiecien, #david-serrano)
EDIT :
Add this at the end of app level build.gradle file
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion "28.0.0"
}
}
}
}
Credit to Eugen Pechanec
I have handled this issue by importing this library as module and replacing dependencies from
dependencies {
api "androidx.appcompat:appcompat:$androidXLibraryVersion"
implementation "androidx.exifinterface:exifinterface:$androidXLibraryVersion"
}
to
dependencies {
api "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:exifinterface:28.0.0"
}
And updating imports in all files of library
if you want to use below
implementation com.theartofdev.edmodo:android-image-cropper:2.8.+
Add two lines in gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Not sure about case but after facing same issue it was because i did not add
tools:replace="android:appComponentFactory"
This line in Manifest
change version don't use + if you use android studio bumblebee, go to setting.gradle, and add jcenter() :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
I get the following error: Please help
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.1) from [com.android.support:design:26.0.1] AndroidManifest.xml:28:13-35
is also present at [com.android.support:appcompat-v7:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:26:9-28:38 to override.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package name">
<uses-permission android:name="android.permission.INTERNET" />
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "package name"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.getbase:floatingactionbutton:1.9.1'
implementation 'com.android.support:design:26.0.1'
}
You have to change your dependencies version like
in your Gradle file
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
add tools:replace="android:value" to application tag in your manifest
Change your all support library as same version like
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
Always use same version for same type library.
for convenience, you can use same version like this
Add this line in app level gradle.
def mySupportVersion = "26.1.0"
Then your dependency line will look like
implementation "com.android.support:appcompat-v7:$mySupportVersion"
implementation "com.android.support:design:$mySupportVersion"
Sync your build version and supported libraries dependencies to the latest version available. And then clean your project. I hope this will resolve your problem.
Worked for me.
Try to add following lines in end of your app module in build.gradle.
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.1.0'
}
}
}
}