Build Failed: Program Type Already Present

program type already present: buildconfig
program type already present: android studio
error program type already present: android studio
d8 program type already present buildconfig
caused by: com.android.tools.r8.utils.abortexception: error: program type already present:
program type already present mainactivity
agpbi: {"kind":"error","text":"program type already present:
program type already present react-native

I have searched online about this error and the issue always seems to end up being some sort of dependency conflict. I think I am supposed to add exclude after certain dependencies, but I am unsure which one(s). It's also unclear based on the error which dependency I should actually exclude; all I know is that the group is probably com.android.support...

Here's what I've tried:

  1. Adding multiDexEnabled true to my defaultConfig block in build.gradle.
  2. Cleaning the project in Android Studio.
  3. Manually deleting (from the file system) the entire .gradle directory.
  4. I've made sure compileSdkVersion and targetSdkVersion are the same.
  5. I've made sure all my Android dependencies use the same version (namely 26.1.0).

Despite all this, I still get this error when I build:

Program type already present: android.support.compat.R$bool

and from the Java compiler:

Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
F:\ExampleProject\app\build\intermediates\transforms\dexBuilder\debug\115, 
F:\ExampleProject\app\build\intermediates\transforms\externalLibsDexMerger\debug\0

Here is my module's build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.myapp.exampleproject"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.2"
    }
    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:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:support-compat:26.1.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.github.bumptech.glide:glide:4.1.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.1.0'
}

and lastly, my project's build.gradle file:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Any help in rectifying this would be greatly appreciated.

This is a problem with Glide 4.1.0. Use the version 4.1.1 instead which fix the bug by remove the R*.class file from their dependencies. (source)

Can't Build. Program type already present: com.example , With multiple warnings and one error. AGPBI: {"kind":"error","text":"Program type already present: com.example.billingsample.BuildConfig  Build Failed with Program type already present in Cmd and Android Studio - F-Droid compilation failure #669 Closed nssharath opened this issue Apr 1, 2019 · 14 comments

This is probably because of Glide library. Try to exclude the support library from it with:

// add support-fragment removed from Glide.
implementation "com.android.support:support-fragment:26.1.0"

implementation ('com.github.bumptech.glide:glide:4.1.0') {
   exclude group: 'com.android.support'
   exclude module: 'support-fragment'
   exclude module: 'appcompat-v7'
}

You can see the support library inside Glide at Glide build.gradle

D8: Program type already present: android.support.v4.app , D8: Program type already present: android.support.v4.app.​INotificationSideChannel FAILURE: Build failed with an exception. * What went  Android Studio Build Failed: Program type already present: com.google.android.gms.location.places.zza #181 LanceMagnaye26 opened this issue Nov 6, 2018 · 4 comments Comments

Solution:

 implementation ('com.github.bumptech.glide:glide:4.1.0') {
        exclude group: 'com.android.support'
        exclude module: 'support-fragment'
        exclude module: 'appcompat-v7'
    }

Program type already present error when gradle build, Hi, When i try to create an android build with gradle. I get this error. I already try to delete and reinstall all sdk's(currently only 3 services i Program type already present: io.flutter.BuildConfig * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Gradle Build Error : Program type already present: com.google.unity , Gradle Build Error : Program type already present: com.google.unity.BuildConfig. Hi everyone I recently updated my project to unity 2019.2.8f  @wmonecke It looks like your issue is that you have "auto-linking" enabled, while also linking some projects manually. In theory this should work with the auto-linking system just ignoring the ones you are manually linking, however, my guess is that because of the special characters in this libraries module name (@react-native-community/netinfo) the name it's checking for is different to the

D8: Program type already present: com.MyCompany.My, Error 1: D8: Program type already present: com.MyCompany. I have two of AndroidManifest.xml files and gradle.build files. Do i really need  Program type already present: io.flutter.BuildConfig * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 40s Running Gradle task ' assembleDebug ' Running Gradle task

When Gradle says "program type already present", Today I helped someone whose Android project was failing to build with a "​program type already present" error about the dependencies. This is actually an Android related problem. When two libraries (e.g AAR files) contain one or more classes with same packageName (e.g com.example.library.Class1), the Gradle can not decide which one to use and include in the main source path, so it'll throw an exception.

Comments
  • Unfortunately, I still get the same error. :(
  • I am able to build it successfully, which android studio version are you using?
  • Android Studio 3.1.2.
  • Thanks for the info + source. I regret to report that the error is still appearing after removing that line (in addition to adding the Glide excludes that were suggested in the other answer).
  • @user9712684 I found the problem inside glide.
  • Wow, that is a really sneaky bug! Thank you so much, that has fixed the problem! :)
  • The error remains the same. Is there something more I should be doing besides cleaning & deleting the .gradle directory before I try to rebuild? I'm paranoid that it's still producing the error because of build files hanging around somewhere...