Here's the Error:
AGPBI: {"kind":"error","text":"Program type already present: android.support.customtabs.ICustomTabsCallback","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\ANDROID\project\app\build\intermediates\transforms\dexBuilder\debug\0.jar, Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.customtabs.ICustomTabsCallback
Here's what on my app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '28.0.3'`
defaultConfig {
multiDexEnabled true
applicationId "com.project.app"
minSdkVersion 16
targetSdkVersion 29
versionCode 6
versionName "1.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
repositories{
maven {
url "http://dl.bintray.com/teads/TeadsSDK-android"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:26.0.1'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.google.android:flexbox:1.1.0'
implementation 'com.flurry.android:analytics:11.4.0@aar'
//implementation 'com.flurry.android:analytics:8.2.0@aar'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.googlecode.json-simple:json-simple:1.1'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
//implementation 'com.google.android.gms:play-services-ads:18.3.0'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
// Required dependency
implementation 'com.google.android.gms:play-services-basement:12.0.1'
// Teads SDK
/*implementation ('tv.teads.sdk:androidsdk:2.5.12:fullRelease@aar') {
transitive = true;
}*/
// Teads SDK
implementation("tv.teads.sdk.android:sdk:4.3.4@aar") {
transitive = true
}
// Teads Admob Adapter
implementation 'tv.teads.sdk.android:admobadapter:4.1.1'
implementation 'org.apmem.tools:layouts:1.10@aar'
}
Can you help me ? What is wrong with my app. It sync successfully but when i build it, the error appear. What should i do? Thanks for advance.
Starting from version 18.0.0
dependency com.google.android.gms:play-services-ads
uses AndroidX packages instead of Support Library. This dependency adds androidx libraries to your project transitively, you can check it using "gradlew app:dependencies" task:
+--- com.google.android.gms:play-services-ads:18.0.0
| +--- androidx.collection:collection:1.0.0
| | \--- androidx.annotation:annotation:1.0.0
| +--- androidx.core:core:1.0.0
| | +--- androidx.annotation:annotation:1.0.0
| | +--- androidx.collection:collection:1.0.0 (*)
| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0
| | | +--- androidx.lifecycle:lifecycle-common:2.0.0
| | | | \--- androidx.annotation:annotation:1.0.0
| | | +--- androidx.arch.core:core-common:2.0.0
| | | | \--- androidx.annotation:annotation:1.0.0
| | | \--- androidx.annotation:annotation:1.0.0
| | \--- androidx.versionedparcelable:versionedparcelable:1.0.0
...
Each androidX dependency contains both android
and androidx
packages. Since gradle sees two different dependencies with the same packages inside, it has no other choice but to throw an error.
As a solution, you can downgrade your 'com.google.android.gms:play-services-ads' to version 17.2.1, since it's the last version that uses old support packages. Other solution might be migrating your project to AndroidX