What does "Program type already present" mean?

This problem usually come from a naming conflict, in your case the support-v4 library, which is use by several libraries.

To find the list of dependencies for the module app (default module's name for the app) we can do a gradlew app:dependencies to retrieve a list of all the libraries.

We found that support-v4 is used by:

//short version of the dependencies list highlighting support-v4
+--- com.android.support:support-v13:27.1.0
|    \--- com.android.support:support-v4:27.1.0

+--- com.google.android.gms:play-services-maps:12.0.1
|    +--- com.google.android.gms:play-services-base:12.0.1
|    |    +--- com.google.android.gms:play-services-basement:12.0.1
|    |    |    +--- com.android.support:support-v4:26.1.0 -> 27.1.0 (*)

+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2
|    +--- com.google.android:support-v4:r7  // <- problem here

We see that the support-v4 on Maps will use the version provided from support-v13.

We also see that the eclipse library is using another version (r7 ??).

To resolve your issue, you can try to exclude the module support-v4 from this eclipse library like this:

implementation ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
    exclude module: 'support-v4'
}

Then you should be able to compile your application.

Btw you should take care that the eclipse module won't break by testing your code.


For me just cleaning the project solved the issue

Using Terminal :

./gradlew clean

Using Android Studio :

Build (menu) > Clean Project

It's happened to me also but in my case, I try to include different dependencies that have same class using debugApi & Api so Android Studio marked as duplicate class, so I solved the issue by using debugApi & releaseApi to include different dependencies based on the build variant.


From official Doc

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. ( See if same library is added as jar and gradle dependency)