0

I am working on a checklist application and one error keeps leading to another. I was instructed to add

implementation 'androidx.recyclerview:recyclerview:1.1.0

and

`implementation com.google.android.material:material:1.1.0`

to my dependencies section within build.gradle (Module: app).

This resulted in the 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.1.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:5:5-19:19 to override."

So in AndroidManifest.xml I added

tools:replace="android:appComponentFactory"

to the top of my "application" element and I added

xmlns:tools="http://schemas.android.com/tools"

to the top of my manifest element. Now I am receiving multiple log errors that all seem to reference "Couldn't load memtrack module". This seems like an error that could be caused by many different factors. I'm having a lot of difficulty figuring this out and I'm wondering if I just messed up somewhere with my initial attempt to implement recyclerview and material. What should I be looking for to fix this?

build.gradle (Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 32
    defaultConfig {
        applicationId "com.example.timks.sanctuarychecklist"
        minSdkVersion 23
        targetSdkVersion 32
        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:+'
    implementation 'com.android.support.constraint:constraint-layout:2.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 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.1.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.example.timks.sanctuarychecklist">

    <application tools:replace="android:appComponentFactory"
        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>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <TextView
        android:id="@+id/tasksText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:text="Sanctuary Inventory"
        android:textSize="40dp"
        android:textColor="@android:color/black"
        android:layout_marginStart="30dp"
        android:layout_marginBottom="16dp"
        android:layout_marginTop="16dp"
        />


</RelativeLayout>

MainActivity.java

package com.example.timks.sanctuarychecklist;

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);
    }
}

1 Answers1

0

I found out that there were three issues causing errors with my app.

1.) My gradle version was set to 4.4 and I updated that to 7.4 to make it compatible. To do that I opened my gradle-wrappers.properties file and updated

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

.

2.) I was missing the appComponentFactory line from the application component in my AndroidManifest.xml file so I inserted the following code.

android:appComponentFactory="@string/app_name"

3.) Within the AndroidManifest.xml file I was also missing the following line from my activity component.

android:exported="true"

So now my gradle-wrappers.properties file and AndroidManifest.xml file look as such and the application is able to successfully build and run.

gradle-wrappers.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

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.example.timks.sanctuarychecklist">

    <application tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:appComponentFactory="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>