I have a problem about android manifest file in my android project after adding ButterKnife dependency in gradle file.
When I run the program, it throws an error shown below.
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:6:5-21:19 to override.
Here is my file.
<application
tools:replace="android:allowBackup,android:icon,android:label,android:roundIcon,android:supportsRtl,android:theme"
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>
Build.gradle file
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'
testİmplementation 'junit:junit:4.12'
androidTestİmplementation 'com.android.support.test:runner:1.0.2'
androidTestİmplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// TODO 1) ButterKnife Library Defined
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
}
You cannot use butterknife:10.x.x unless you also migrated to AndroidX. If you haven't migrated, you'll need to stick to 9.0.0 for now. Once you migrate, then you can update to 10.1.0 (or whatever is latest at that time). –
Related
I'm developing an app and I want to add an admob banner add to it. I asked the permissions in the manifest file for Internet and for the network state. Then I added the dependency for admob. After entering the dependency to the gradle file, the app in my phone app crashes during testing.
It happens when I add the dependency. I want to find the correct dependency or some how fix this if this happens because of another reason.
Here are the dependencies I added:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
}
You need to add below Meta tag inside of Aplication in your Manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
//Add this
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_id" /> //Add here your admob app id
...
</application>
I hope this can help you!
Thank You.
I think you need to add 2 meta-data tags inside the manifest xml of your application.
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_id" /> // put your admob app id in quotes
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Hope this helps
This question already has an answer here:
play-services-ads conflicts with appcompat
(1 answer)
Closed 3 years ago.
Iv have an immediate conflict on an empty project once I implement gplay services.
On the latest android studio on mac, i create a simple activity app:
mainactivity:
package semy.apps.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
then once i add implementation 'com.google.android.gms:play-services-ads:18.1.1' on build.gradle
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 'com.google.android.gms:play-services-ads:18.1.1'
}
i get
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:5:5-19:19 to override.
i try to add those tags on manifest to no avail, still doesnt work
A quick solution to your problem could be to add the following 3 lines in your AndroidMannifest.xml
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="#string/app_name"
So, after adding the above 3 lines your AndroidMannifest.xml should look like,
AndroidMannifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<!--Add the following 3 lines-->
<application
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="#string/app_name"
...
>
<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>
EDIT: Update your dependencies to the latest version as play-services-ads is using androidx version of support library and you are using the traditional one.
build.gradle (Module: app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout: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-ads:18.2.0'
}
I hope it will fix your build error. Let me know if it works?
Running my app got this error:
Manifest merger failed : 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 <application> element at AndroidManifest.xml:7:5-117 to override.
I've tried to add to gradle.properties
android.useAndroidX=true
android.enableJetifier=true
and also (to AndroidManifest)
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
and also (to build.gradle)
implementation "androidx.appcompat:appcompat:1.0.0"
replacing the previous
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
but not working for me.
-- Android Manifest.xml --
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
-- build.gradle --
dependencies {
implementation project(':react-native-exit-app')
implementation project(':react-native-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompatv7:
${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:17.0.0"
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
}
It means that one of your libraries is using AndroidX. So, you have to convert your app to AndroidX.
android.useAndroidX=true android.enableJetifier=true Put these lines in your gradle.properties.
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)
I am working on my app.Everything was ok but i do not know why i got this error when i tried to run the application:
Execution failed for task ':inteligentestate:processDebugManifest'.
> 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:6:5-28:19 to override.
from the error suggestion i added tools:replace="android:appComponentFactory" in my main application manifest:
<application
android:name=".application.App"
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"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory">
When i run my app i got this error:
Task :inteligentestate:processDebugManifest FAILED
/mnt/main/Project/.../AndroidManifest.xml:6:5-29:19 Error:
tools:replace specified at line:6 for attribute android:appComponentFactory, but no new value specified
/mnt/main/Tutorial/Android/project/.../AndroidManifest.xml Error:
Validation failed, exiting
I googled and I found this post .
I'm not using androidX
This is my project dependencies:
dependencies {
// Support
implementation "com.android.support:design:${versions.supportLib}"
implementation "com.android.support:recyclerview-v7:${versions.supportLib}"
implementation "com.android.support:cardview-v7:${versions.supportLib}"
implementation "com.android.support:gridlayout-v7:${versions.supportLib}"
implementation "com.android.support:customtabs:${versions.supportLib}"
// room
implementation "android.arch.persistence.room:runtime:${versions.room}"
annotationProcessor "android.arch.persistence.room:compiler:${versions.room}"
implementation "android.arch.persistence.room:rxjava2:${versions.room}"
// Network
implementation "com.google.code.gson:gson:${versions.gson}"
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
implementation "com.squareup.retrofit2:converter-gson:${versions.retrofit}"
implementation "com.squareup.okhttp3:logging-interceptor:${versions.interceptor}"
//rx java
implementation "io.reactivex.rxjava2:rxandroid:${versions.rxAndroidVersion}"
implementation "io.reactivex.rxjava2:rxjava:${versions.rxJavaVersion}"
//Other
implementation "com.jakewharton.timber:timber:${versions.timber}"
implementation "com.jakewharton:butterknife:${versions.butterknife}"
annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterknife}"
implementation "com.google.dagger:dagger:${versions.dagger}"
annotationProcessor "com.google.dagger:dagger-compiler:${versions.dagger}"
// Testing
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 project(path: ':map')
}
And library dependancies:
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api "com.android.support.constraint:constraint-layout:${versions.constraintLayout}"
api "com.android.support:appcompat-v7:${versions.supportLib}"
api "com.android.support:support-v4:${versions.supportLib}"
// Mapbox
api "com.mapbox.mapboxsdk:mapbox-android-sdk:${versions.mapboxMapSdk}"
api "com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:${versions.mapboxPluginLocalization}"
I found this post anber mentioned that
project has different versions of the same library
But i think my project's library is the same!!!
Solution: Android Studio => Refactor Menu => Migrate to AndroidX.
Yes it's easy.
Go to your application manifest and at bottom you'll see mergedManifest option
navigate to mergedManifest bottom where it will tell your what you've error and in what file
See you error closer. It's mostly error in our layout file that's why merged Manifest don't works
Hope so it will solve your error!!!
please try downgrade your gradle version and restart Android studio
I was getting started with Lottie when I came across this error. I added the dependency to my build.gradle
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'com.airbnb.android:lottie:2.8.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
implementation 'com.android.support:design: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'
Since I added implementation 'com.airbnb.android:lottie:2.8.0' build succeeds but I cant run my application as there is an error in the Manifest Merging.
Merging Errors: Error: Attribute application#appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:22:18-86 is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:14:5-35:19 to override. app main manifest (this file), line 21
Here is my Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="com.rishav.sanfoundryfer">
<dist:module dist:instant="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:logo="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".QuestionActivity"
android:label="MCQs"/>
<activity android:name=".TopicActivity"
android:label="Select Topic"/>
<activity android:name=".SubjectActivity"
android:label="Select Subject"/>
<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>
The fact that the error has androidx.core.app.CoreComponentFactory points to the fact that the new "Jetpack" support library packages are being used. Seeing that your manifest uses the "older" packages points to the fact that it probably is used by lottie.
You can make sure that this is the reason by inspecting the library.
To resolve the issue you can use an older lottie library, start using the jetpack support library packages or resolve the merge manually. You can take a look at the merged manifest if you navigate to the AndroidManifest.xml and switch to the Merged Manifest tab at the bottom of the window.
Suggestion:
add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:14:5-35:19 to override.app main manifest (this file), line 21