Manifest merger failed android studio - android-studio

I have this in my build.gradle(module:app) :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-
layout:1.1.3'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
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:recyclerview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
}
and when I try to sync it displays this:
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:9:5-32:19 to override.
what can cause this and how do I fix it?
(adding tools:replace="android:appComponentFactory" to the manifest doesn't work)

Your android-image-cropper library is using androidx, while you haven't migrated yet. It is highly recommended to migrate to using Androidx, since most of the libraries are doing the same and may not provide backward compatibility to the com.android.support variants.
If you cannot migrate in the short term, then you can revert to a lower version of the library. As per the changelog, they migrated to AndroidX in 2.8.0, so you should go back to 2.7.0.

Related

Android Studio Arctic fox test run shows "nothing here"

I've tried so many things from invalidate cache/restart to clean re installing android studio multiple times now. nothing seems to work.
in my build.gradle (project level)
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
...
build.gradle (app level)
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
}
I've enabled corretto-1.8 version of the gradle jdk in settings and the plugins for JUint is enabled.
I cannot seems to find any solution to this issue.
P.S. I have update the windows to windows 11 recently. The above issue was persisting before that.

Version 28 is the latest version of the legacy support

Hello iam trying to add this library :compile 'com.android.support:cardview-v7:28.0.0\n'
but getting error: Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX...
any fix?
Bro its very simple just change
com.android.support:cardview-v7:(your targetsdkversion digits).0.0
instead of com.android.support:cardview-v7:28.0.0...it will work
Use the following dependencies instead of old ones in gradle scripts on Module level
dependencies {
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

Version Conflict either updating the version of the google-services plugin

So I tried to connect my firebase database to my android studio application.I get this error:
Please fix the version conflict either by updating the version of the
google-services plugin (information about the latest version is
available at
https://bintray.com/android/android-tools/com.google.gms.google-services/)
or updating the version of com.google.android.gms to 9.0.0.
I changed the version but it still does not work. As you can see I changed the version 16.
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'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.4'
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'
}
I don't see the problem. I am stuck on this for hours.
Make sure You have gms classpath provided in your Project build.gradle, like this:
dependencies {
...
classpath 'com.google.gms:google-services:4.3.2'
}

Error in Appcompat Dependencies when implementing MaterialProgressBar in build.gradle

I'm getting an error in my implementation 'com.android.support:appcompat-v7:28.0.0' at build.gradle file after implementing implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
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'
implementation 'com.android.support:design:28.0.0'
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
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'
}
I've already tried using
android.useAndroidX=true and
android.enableJetifier=true
Inside gradle.properties file but then I got another error in my MainActivity.kt file
Here's the error message :
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='cardview-v7', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.lifecycle', myArtifactId='lifecycle-viewmodel', myVersion='2.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
Is there a way to fix this error? thank you!
AndroidX and Compat shouldn't be used together,AndroidX library was introduced to remove Compat Libraries.
Turn off
android.useAndroidX=false and
android.enableJetifier=true
Post your complete app gradle file. There is a library in your dependency that is using a version lower than your targetSdkVersion.

Android Studio can not resolve AutoValue class

I started to use AutoValue today in one of my projects and what bothers me is that Android Studio can not resolve the generated class name (AutoValue_DrawableContent) and marks it with the red color:
How I can suppress this warning?
Add the "idea" plugin to your build.gradle, for example:
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'net.ltgt.apt'
With this plugin, Android Studio can find the generated source files.
you can just comment out each dependencies and sync one by one... it might get things fixed...
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
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'
Now that you have annotated your class, you need to build your project. This will generate the missing class, and Android Studio will be able to find it afterwards.
The build will not fail even though the editor is currently not recognizing the class name, because code generation will happen before the class is compiled.
Generate implementation class(es). AutoValue lib will do that.
Add these dynamically class(es) directory into source path. android-apt plugin will do this. After doing this, ide will know AutoValue_* and not to show errors.

Resources