1
votes

Trying the following code to run an application but am getting the following error."Manifest merger failed with multiple errors, see logs". I made some changes in the app gradle file earlier as the application involves use of "CardView and Recycler view"(Changes was advised on few questions in stackoverflow) Attaching all the app files below. Can someone please help me on this ? Gradle Console:

Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\Sumeet\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Observed package id 'add-ons;addon-google_apis-google-23' in inconsistent location 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1' (Expected 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23')
Already observed package id 'add-ons;addon-google_apis-google-23' in 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23'. Skipping duplicate at 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1'
Observed package id 'add-ons;addon-google_apis-google-23' in inconsistent location 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1' (Expected 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23')
Already observed package id 'add-ons;addon-google_apis-google-23' in 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23'. Skipping duplicate at 'C:\Users\Sumeet\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1'
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2531Library
:app:prepareComAndroidSupportAppcompatV72531Library
:app:prepareComAndroidSupportCardviewV72103Library
:app:prepareComAndroidSupportConstraintConstraintLayout100Beta5Library
:app:prepareComAndroidSupportDesign2220Library
:app:prepareComAndroidSupportRecyclerviewV72600Alpha1Library
:app:prepareComAndroidSupportSupportCompat2600Alpha1Library
:app:prepareComAndroidSupportSupportCoreUi2600Alpha1Library
:app:prepareComAndroidSupportSupportCoreUtils2531Library
:app:prepareComAndroidSupportSupportFragment2531Library
:app:prepareComAndroidSupportSupportMediaCompat2531Library
:app:prepareComAndroidSupportSupportV42531Library
:app:prepareComAndroidSupportSupportVectorDrawable2531Library
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest
C:\Users\Sumeet\Desktop\Workspace\CardViewReclyerView_try1\app\src\main\AndroidManifest.xml:27:9-31 Error:
    Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
    is also present at [com.android.support:recyclerview-v7:26.0.0-alpha1] AndroidManifest.xml:24:9-38 value=(26.0.0-alpha1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.
C:\Users\Sumeet\Desktop\Workspace\CardViewReclyerView_try1\app\src\main\AndroidManifest.xml Error:
    uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.support:recyclerview-v7:26.0.0-alpha1] C:\Users\Sumeet\.android\build-cache\b9c913425a87cdfd18c66664e6c35b4ec1a4f53e\output\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.v7.recyclerview" to force usage


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

:app:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stack trace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2 mins 18.389 secs

MainActivity.java

    package com.example.sumeet.cardviewreclyerview_try1;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_home, menu);
        return super.onCreateOptionsMenu(menu);
    }
}

VersionAdapter.java

package com.example.sumeet.cardviewreclyerview_try1;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by Sumeet on 03-04-2017.
 */

public class VersionAdapter extends RecyclerView.Adapter<VersionAdapter.VersionViewHolder> {

    private String[] version = {"Alpha", "Beta", "CupCake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow", "Nougat", "O"};

    @Override
    public VersionAdapter.VersionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {


        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.each_row, parent, false);
        VersionViewHolder viewHolder = new VersionViewHolder(v);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(VersionAdapter.VersionViewHolder holder, int position) {
        holder.text.setText(version[position]);
    }

    @Override
    public int getItemCount() {
        return version.length;
    }

    public static class VersionViewHolder extends RecyclerView.ViewHolder {
        private TextView text;

        public VersionViewHolder(View itemView) {
            super(itemView);
            text = (TextView) itemView.findViewById(R.id.textview_card);
        }
    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.sumeet.cardviewreclyerview_try1.MainActivity">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        android:layout_above="@+id/floatingActionButton"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"></android.support.v7.widget.RecyclerView>

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:clickable="true"
        android:src="@android:drawable/ic_dialog_email"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="312dp"
        tools:layout_editor_absoluteY="439dp"
        android:id="@+id/floatingActionButton" />

</RelativeLayout>

each_row.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:id="@+id/textview_card"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Name" />
</android.support.v7.widget.CardView>

menu_home.xml(The Menu File)

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/add_item"
        android:icon="@android:drawable/ic_menu_add"
        android:title="Item"
        app:showAsAction="always" />
    <item
        android:id="@+id/delete_item"
        android:icon="@android:drawable/ic_menu_delete"
        android:title="Item"
        app:showAsAction="always" />
    <item
        android:id="@+id/search_item"
        android:title="Search" />
    <item
        android:id="@+id/settings_item"
        android:title="Settings" />
</menu>

build.gradle(app)

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.sumeet.cardviewreclyerview_try1"
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        compile 'com.android.support:cardview-v7:21.+'
        compile 'com.android.support:recyclerview-v7:21.+'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
    compile 'com.android.support:recyclerview-v7:+'
    testCompile 'junit:junit:4.12'
}
1

1 Answers

7
votes

You are attempting to use multiple versions of the Android Support Library:

  • compile 'com.android.support:appcompat-v7:25.3.1'
  • compile 'com.android.support:design:22.2.0'
  • compile 'com.android.support:recyclerview-v7:+'

Use the same version for all com.android.support artifacts. And that version should not be +. Given these three lines, I would go with 25.3.1.