0

I trying to user multiple module android project to work on my application and when I try to build the project. the project build fails with Manifest merge failures. I need help to resolve this issue.

I already tried changing the dependencies in Gradle files and tried rearranging them, searched other solutions in this and here as well, but none of them helped

my AndroidManifest.xml file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.atomnest.chitfund">

    <application
        xmlns:tools="http://schemas.android.com/tools"
        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:replace="android:appComponentFactory" />
</manifest>

since the project is not build successfully I'm not able to add any activity to the project and my build.gradle File

apply plugin: 'com.android.application'

buildscript {
    ext {
        support_version = '1.0.2'
    }
    repositories {
        mavenCentral()
    }
}

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.atomnest.chitfund"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-storage:16.0.5'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation "androidx.appcompat:appcompat:$support_version"
    implementation 'com.jakewharton:butterknife:9.0.0-rc2'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'com.firebase:geofire-android:2.1.1'
    implementation project(':utility')
    implementation project(':library')
}

I am expecting to get the project build successfully and be able to launch the app in the emulator. pls help

here is the logcat image logcat image

madhu s
  • 140
  • 2
  • 14

3 Answers3

0

If you are using androidx then you have to use all libraries compatible with androidx so you can use this code:-

In gradle.build (app) add this

compileSdkVersion 28
    defaultConfig {
        ......
        minSdkVersion 21
        targetSdkVersion 28
        ......
    }

And there are some implementations required to use androidx :-

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

And add these given two lines(below) to gradle.properties:-

android.useAndroidX=true
android.enableJetifier=true
DeePanShu
  • 1,236
  • 10
  • 23
0

Solution 1:

Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml to override.

If you added the tools:replace="android:appComponentFactory" and still got trouble by fixing it, create a new project, copy-paste the codes and the same dependencies in there. After that, it should be fixed i hope.


If it didn't solve the issue, try adding these two:

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

In AndroidManifest.xml > <application tag of course.

Solution 2:

Add below two lines in gradle.properties

android.useAndroidX=true
android.enableJetifier=true

You can also follow below link:

https://developer.android.com/jetpack/androidx/migrate

Do let me know if you get any problem.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
  • I did add the above-mentioned lines in gradle.properties as mentioned by @Deepanshu it shows The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx. and its a error again – madhu s Jan 29 '19 at 06:41
  • @Pratin_Bhtani for the solution 1 you mentioned its the third time created the new project migrated my code to it, it doesn't help in my case. – madhu s Jan 29 '19 at 06:50
0

Actually I had the same issue.In my case it was butterknife. I changed the dependency into 8.8.1 and it works fine for me.