Abm
Abm

Reputation: 311

Error in gradle

Getting gradle issue while sync. app level gradle files

Manifest.xml

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.aparna.search_recy">

    <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"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

build.gradle

    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.aparna.search_recy"
        minSdkVersion 21
        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'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-v13:26.1.0'
    implementation 'com.android.support:design: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.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:cardview-v7:26.0.2'
}

ERROR:

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.1.0) from [com.android.support:support-v13:26.1.0] AndroidManifest.xml:28:13-35 is also present at [com.android.support:cardview-v7:26.0.2] AndroidManifest.xml:25:13-35 value=(26.0.2). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:26:9-28:38 to override.

Upvotes: 0

Views: 1874

Answers (7)

aderw
aderw

Reputation: 41

For me enabling jetifier and androidx resolved this error

Upvotes: 0

codingjeremy
codingjeremy

Reputation: 5741

Just add the library in the error to your build.gradle but change the version to match whatever you are using with the other library.

For me, my build.gradle file had this:

implementation 'com.android.support:appcompat-v7:27.1.1'

I got this error:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:recyclerview-v7:26.0.2] AndroidManifest.xml:25:13-35 is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override.

So I added recyclerview-v7:26.0.2 to by build.gradle but changed it to 27.1.1 to match my appcompat-v7. I built it again and got a similar error but this time for com.android.support:percent:26.0.2.

I again added that to my gradle.build file but changed it to 27.1.1 to match my appcompat-v7.

In summary, this:

implementation 'com.android.support:appcompat-v7:27.1.1'

Became this

implementation 'com.android.support:appcompat-v7:27.1.1'
// Had to add recyclerview
implementation 'com.android.support:recyclerview-v7:27.1.1'
// Had to add percent
implementation 'com.android.support:percent:27.1.1'

Then it worked fine.

I guess appcompat-v7 must have those older versions of the libraries hard coded into it.

Upvotes: 0

leooooooo
leooooooo

Reputation: 429

Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:26:9-28:38 to override.

This problem occurs because when you use different libs, the AndroidManifest in them conflict with each other.

Upvotes: 0

Sachin Rajput
Sachin Rajput

Reputation: 4344

Actually, this error comes if you use different different versions in your dependency.

To avoid this error you just need to change your cardview-v7:26.0.2 version to 26.1.0.

It will solve your problem

Upvotes: 1

Manish Singh Rana
Manish Singh Rana

Reputation: 872

Try these combinations. Because versions were mixed in dependencies which lead to runtime crashes while building gradle.
All com.android.support libraries must use the exact same version specification.There are some combinations of libraries, or tools and libraries, that are incompatible or can lead to bugs.

Replace dependencies with below-mentioned dependencies.

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:design:27.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.mcxiaoke.volley:library:1.0.19'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'

Upvotes: 0

Omkar
Omkar

Reputation: 3100

First you may add missing buildToolVersion below compileSdkVersion then use same version also missing compile 'com.android.support:recyclerview-v7: version so add this check below code

      android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1" //change here
    defaultConfig {
        applicationId "com.aparna.search_recy"
        minSdkVersion 21
        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'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-v13:26.1.0'
    implementation 'com.android.support:design: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.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support:recyclerview-v7:26.1.0' //change here
    compile 'com.android.support:cardview-v7:26.1.0'
}

finally clean and rebuild project if this not worked goto File->Invalidate Caches / Restart

Upvotes: 2

Ege Kuzubasioglu
Ege Kuzubasioglu

Reputation: 6282

change your cardview-v7:26.0.2 version to 26.1.0

Upvotes: 0

Related Questions