Android Studio运行时错误Program type already present含义及解决求助
Hey there! Let's break down what this error means and walk through how to fix it step by step.
What This Error Means
The error Program type already present: android.support.v7.util.AsyncListUtil$DataCallback is a duplicate class conflict. This happens when the same Java class gets included in your project multiple times—either from direct duplicate dependency declarations, or from third-party libraries pulling in older versions of support libraries that clash with the ones you’ve explicitly added.
Looking at your dependency setup, there are clear culprits here:
- Duplicate declarations of the same dependencies (e.g.,
play-services-adsappears 3 times,play-services-locationis declared twice) - Mismatched versions of Android Support libraries (e.g.,
appcompat-v7:27.1.1vsdesign:27.1.0) - Mixing outdated
compilesyntax with modernimplementation(Google recommends usingimplementationnow, ascompileis deprecated)
Step-by-Step Fixes
1. Clean Up Duplicate & Mismatched Dependencies
First, we’ll remove redundant declarations and align all support library versions to match. Here’s a cleaned-up version of your dependencies (I’ve replaced compile with implementation and fixed version mismatches):
// Android Support Libraries (all using the same version: 27.1.1) implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:support-annotations:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support:multidex:1.0.3' // Google Play Services & Firebase (all using 15.0.0 to avoid version conflicts) implementation 'com.google.android.gms:play-services-location:15.0.0' implementation 'com.google.android.gms:play-services-auth:15.0.0' implementation 'com.google.android.gms:play-services-ads:15.0.0' implementation 'com.google.android.gms:play-services-base:15.0.0' implementation 'com.google.android.gms:play-services-plus:15.0.0' implementation 'com.google.firebase:firebase-auth:15.0.0' implementation 'com.google.firebase:firebase-database:15.0.0' // Third-party libraries implementation 'com.squareup.picasso:picasso:2.5.2' // Inmobi/MobVista libraries (exclude built-in support libraries to prevent clashes) implementation(name: 'adcolony-sdk-3.2.1', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mmedia-6.4.0', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_alphab', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_appwall', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_appwallext', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_common', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_interstitial', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_mvdownloads', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_mvjscommon', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_mvnative', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_nativeex', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_offerwall', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_playercommon', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_reward', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_videocommon', ext: 'aar') { exclude group: 'com.android.support' } implementation(name: 'mobvista_videofeeds', ext: 'aar') { exclude group: 'com.android.support' } // Testing dependencies 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'
2. Exclude Indirect Support Library Conflicts
I added exclude group: 'com.android.support' to all your MobVista AAR dependencies. This is because many third-party ad libraries bundle their own older support libraries, which will clash with the ones you’ve declared explicitly. Excluding them ensures only your specified support library versions are used.
3. Verify Multidex Setup
You already have the multidex dependency, but make sure your AndroidManifest.xml enables it:
Add android:name="android.support.multidex.MultiDexApplication" to your <application> tag, like this:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:hardwareAccelerated="true" android:theme="@style/AppTheme" android:name="android.support.multidex.MultiDexApplication"> <!-- Your activities go here --> </application>
If you have a custom Application class, have it extend MultiDexApplication instead of Application, or override attachBaseContext() and call MultiDex.install(this).
4. Clean & Rebuild Your Project
After updating your dependencies and manifest:
- Click File -> Sync Project with Gradle Files
- Click Build -> Clean Project
- Click Build -> Rebuild Project
This will clear any cached build files and ensure your project uses the updated dependency setup.
Note About Your Manifest
Your AndroidManifest.xml doesn’t appear to be the cause of this error—all permissions and activity declarations look valid. The issue is definitely rooted in duplicate/mismatched dependencies.
内容的提问来源于stack exchange,提问作者JoeMister

