Program type already present:


Android Problem Overview

I have upgraded my Android Studio and I found many problems in the latest version.

Although many similar questions exist, I checked the answers to all and none of them worked for me!

Here is the error I'm facing while compiling the code:

> Program type already present: >$Op > Message{kind=ERROR, text=Program type already present: >$Op, sources=[Unknown source file], tool > name=Optional.of(D8)}

Here is my gradle file:


// Top-level build file where you can add configuration options common to 

all sub-projects/modules.

buildscript {

repositories {
dependencies {
    classpath ''

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

 allprojects {
 repositories {
    maven {
        url ""

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


apply plugin: ''

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.alcantara.bugismart"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation ''
    implementation ''
    testImplementation 'junit:junit:4.12'
    androidTestImplementation ''
    androidTestImplementation ' 
    implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'

You can tell me if there is anything else to add to understand what I'm doing or where I'm wrong.

Android Solutions

Solution 1 - Android

> Program type already present: >$Op > Message{kind=ERROR, text=Program type already present: >$Op, sources=[Unknown source file], tool > name=Optional.of(D8)}

The problem is happened because of duplicated support library. This dependency:

implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'

is using old version of support library. Try excluding the support library if you already have it with:

// support libraries we want to use
implementation ''
implementation ''

// we already have the specific support libraries. So, exclude it
implementation ('com.github.ViksaaSkool:AwesomeSplash:v1.0.0') {    
    exclude group: ''
    exclude module: 'appcompat-v7'
    exclude module: 'support-v4'

You need to check your dependencies with the following command:

./gradlew app:dependencies

Or alternatively, you can always override the support libraries version by adding the conflicted libraries with the exact version that you want.


There is a full step to fixing the dependency resolution errors at the Add build dependencies documentation. Here the excerpts:

Fix dependency resolution errors

When you add multiple dependencies to your app project, those direct and transitive dependencies might conflict with one another. The Android Gradle Plugin tries to resolve these conflicts gracefully, but some conflicts may lead to compile time or runtime errors.

To help you investigate which dependencies are contributing to errors, inspect your app's dependency tree and look for dependencies that appear more than once or with conflicting versions.

If you can't easily identify the duplicate dependency, try using Android Studio's UI to search for dependencies that include the duplicate class as follows:

  1. Select Navigate > Class from the menu bar.
  2. In the pop-up search dialog, make sure that the box next to Include non-project items is checked.
  3. Type the name of the class that appears in the build error.
  4. Inspect the results for the dependencies that include the class.

The following sections describe the different types of dependency resolution errors you may encounter and how to fix them.

Fix duplicate class errors

If a class appears more than once on the runtime classpath, you get an error similar to the following:

Program type already present com.example.MyClass

This error typically occurs due to one of the following circumstances:

  • A binary dependency includes a library that your app also includes as a direct dependency. For example, your app declares a direct dependency on Library A and Library B, but Library A already includes Library B in its binary.

    • To resolve this issue, remove Library B as a direct dependency.
  • Your app has a local binary dependency and a remote binary dependency on the same library.

    • To resolve this issue, remove one of the binary dependencies.

Fix conflicts between classpaths

When Gradle resolves the compile classpath, it first resolves the runtime classpath and uses the result to determine what versions of dependencies should be added to the compile classpath. In other words, the runtime classpath determines the required version numbers for identical dependencies on downstream classpaths.

Your app's runtime classpath also determines the version numbers that Gradle requires for matching dependencies in the runtime classpath for the app's test APK. The hierarchy of classpaths is described in figure below:

enter image description here

A conflict where different versions of the same dependency appears across multiple classpaths migh occur when, for example, your app includes a version of a dependency using the implementation dependency configuration and a library module includes a different version of the dependency using the runtimeOnly configuration.

When resolving dependencies on your runtime and compile time classpaths, Android Gradle plugin 3.3.0 and higher attempt to automatically fix certain downstream version conflicts. For example, if the runtime classpath includes Library A version 2.0 and the compile classpath includes Library A version 1.0, the plugin automatically updates the dependency on the compile classpath to Library A version 2.0 to avoid errors.

However, if the runtime classpath includes Library A version 1.0 and the compile classpath includes Library A version 2.0, the plugin does not downgrade the dependency on the compile classpath to Library A version 1.0, and you still get an error similar to the following:

Conflict with dependency 'com.example.library:some-lib:2.0' in project 'my-library'.
Resolved versions for runtime classpath (1.0) and compile classpath (2.0) differ.

To resolve this issue, do one of the following:

  • Include the desired version of the dependency as an api dependency to your library module. That is, only your library module declares the dependency, but the app module will also have access to its API, transitively.

  • Alternatively, you can declare the dependency in both modules, but you should make sure that each module uses the same version of the dependency. Consider configuring project-wide properties to ensure versions of each dependency remain consistent throughout your project.

Solution 2 - Android

Add this in your App module build.gradle:

implementation ''

Solution 3 - Android

An alternative to the accepted answer is to tell gradle to force the newer version:

final SUPPORT_LIB_VER = '27.1.1'

configurations.all {
    resolutionStrategy { 
        force "${SUPPORT_LIB_VER}"
        force "${SUPPORT_LIB_VER}"

This can be more convenient when you have many dependencies.

see also: Answer to "How can I force Gradle to set the same version for two dependencies?"

Solution 4 - Android

Add this line of Code in dependencies section of your gradle file

implementation ''

Solution 5 - Android

Add this code to gradle according to your "SdkVersion":

implementation ''

for example, my SDKVersion is 28 then I use this code:

implementation ''
implementation ''

Solution 6 - Android

Also check your libs folder because:

implementation fileTree(dir: 'libs', include: ['*.jar'])

will pick all jars from there too. You might have jars duplicating each other or your lower implementations.

I had duplicates in my libs and got this problem.

Solution 7 - Android

In my case, I converted a very old Eclipse project into Android Studio. So, automatic migration used:

dependencies {
    compile files('libs/android-support-v13.jar')

Just remove or comment at the line with this library.

When I commented, Gradle scripted executed correctly.

Solution 8 - Android

> replace you dependencies with it.

implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation ''
    testImplementation 'junit:junit:4.12'
    androidTestImplementation ''
    androidTestImplementation ''

Solution 9 - Android

multiDexEnabled true add the line above in android block in gradle-app its work for me ...

Solution 10 - Android

enter image description here I tried those :

  • clean / rebuild
  • Invalidate cash and restart
  • Exclude dependencies from my library in my app.gradle (see below)

implementation (project(':libxmiimp')) {exclude group: '', module: 'support-v4'}

  • Playing with gradle settings (things like multiDex enable true and other)

But my probleme was that Android-support-v4.jar somehow got into my local android library`s lib folder.... Deleting it fixed my problem


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKurniawan AlcantaraView Question on Stackoverflow
Solution 1 - Androidישו אוהב אותךView Answer on Stackoverflow
Solution 2 - Androidkeval koriaView Answer on Stackoverflow
Solution 3 - AndroidTmTronView Answer on Stackoverflow
Solution 4 - AndroidAreeba QurashiView Answer on Stackoverflow
Solution 5 - AndroidMasoud SiahkaliView Answer on Stackoverflow
Solution 6 - AndroidBoris GafurovView Answer on Stackoverflow
Solution 7 - AndroidVyacheslavView Answer on Stackoverflow
Solution 8 - AndroidVijay KumarView Answer on Stackoverflow
Solution 9 - AndroidMonemView Answer on Stackoverflow
Solution 10 - AndroidAlessandro VerrecchiaView Answer on Stackoverflow