Onesignal-android-sdk: Duplicate class android.support.customtabs.BuildConfig found in modules classes.jar

Created on 21 May 2019  路  6Comments  路  Source: OneSignal/OneSignal-Android-SDK

When i add all the code of OneSignal into the build.gradle in module app i get an error: Duplicate class android.support.customtabs.BuildConfig found in modules classes.jar (com.android.support:customtabs:27.0.2) and classes.jar (com.github.GoogleChrome.custom-tabs-client:customtabs:f7f1f6483c)

this is my gradle:

buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: 'com.android.application'

def twaManifest = [

applicationId: 'org.chromium.twa.svgomg',
hostName: 'www.revcellonline.com', // The domain being opened in the TWA.
launchUrl: '/', // The start path for the TWA. Must be relative to the domain.
name: 'SVGOMG TWA', // The name shown on the Android Launcher.
themeColor: '#303F9F', // The color used for the status bar.
backgroundColor: '#bababa' // The color used for the splash screen background.

]

android {
compileSdkVersion 28
defaultConfig {
manifestPlaceholders = [
onesignal_app_id: '49c4282d-f628-4994-a222-ddf6f8bcb57a',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]

    applicationId twaManifest.applicationId
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 3
    versionName "1.1.1"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    // The name for the application on the Android Launcher
    resValue "string", "appName", twaManifest.name

    // The URL that will be used when launching the TWA from the Android Launcher
    resValue "string", "launchUrl", "https://" + twaManifest.hostName + twaManifest.launchUrl

    // The hostname is used when building the intent-filter, so the TWA is able to
    // handle Intents to open https://svgomg.firebaseapp.com.
    resValue "string", "hostName", twaManifest.hostName

    // This variable below expresses the relationship between the app and the site,
    // as documented in the TWA documentation at
    // https://developers.google.com/web/updates/2017/10/using-twa#set_up_digital_asset_links_in_an_android_app
    // and is injected into the AndroidManifest.xml
    resValue "string", "assetStatements",
            '[{ "relation": ["delegate_permission/common.handle_all_urls"],' +
                    '"target": {"namespace": "web", "site": "https://' +
                    twaManifest.hostName + '"}}]'

    // This attribute sets the status bar color for the TWA. It can be either set here or in
    // `res/values/colors.xml`. Setting in both places is an error and the app will not
    // compile. If not set, the status bar color defaults to #FFFFFF - white.
    resValue "color", "colorPrimary", twaManifest.themeColor

    // Sets the color for the background used for the splash screen when launching the
    // Trusted Web Activity.
    resValue "color", "backgroundColor", twaManifest.backgroundColor

    // Defines a provider authority fot the Splash Screen
    resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
}
buildTypes {
    release {
        minifyEnabled false
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:f7f1f6483c'
implementation 'com.onesignal:OneSignal:3.10.8'
}

this is my manifest:
package="com.placeholder">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/appName"
    android:supportsRtl="true"
    android:theme="@style/Theme.LauncherActivity">

    <meta-data
        android:name="asset_statements"
        android:resource="@string/assetStatements" />

    <activity android:name="android.support.customtabs.trusted.LauncherActivity"
        android:label="@string/appName">
        <meta-data android:name="android.support.customtabs.trusted.DEFAULT_URL"
            android:value="@string/launchUrl" />

        <meta-data
            android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
            android:resource="@color/colorPrimary" />

        <meta-data android:name="android.support.customtabs.trusted.SPLASH_IMAGE_DRAWABLE"
            android:resource="@drawable/splash"/>

        <meta-data android:name="android.support.customtabs.trusted.SPLASH_SCREEN_BACKGROUND_COLOR"
            android:resource="@color/backgroundColor"/>

        <meta-data android:name="android.support.customtabs.trusted.SPLASH_SCREEN_FADE_OUT_DURATION"
            android:value="300"/>

        <meta-data android:name="android.support.customtabs.trusted.FILE_PROVIDER_AUTHORITY"
            android:value="@string/providerAuthority"/>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="https"
                android:host="@string/hostName"/>
        </intent-filter>
    </activity>

    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="@string/providerAuthority"
        android:grantUriPermissions="true"
        android:exported="false">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/filepaths" />
    </provider>

</application>

Im building a pwa to upload to the play store, and everything goes well, but as soon as i add all the code of the oneSignal the error appears

I already tried to exclude com.android.support:customtabs:27.0.2 but it keeps me showing the error.

Help Wanted Needs More Information

Most helpful comment

 implementation ('com.onesignal:OneSignal:3.12.7') {
      //  exclude group: "com.android.support", module: "support-v4"
        exclude group: "com.android.support", module: "customtabs"
    }

This will work :)

All 6 comments

It looks like the problems is caused when i add the dependency
dependencies {
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
}

when i add the dependency my Main Class gets broke with a lot of errors

@murillogalvezj I am not sure where the module com.github.GoogleChrome.custom-tabs-client:customtabs is being imported from or what it's dependencies are. Does this provide something different than the Android Support Library / AndroidX version of customtabs? com.android.support:customtabs

com.github.GoogleChrome.custom-tabs-client:customtabs might be using AndroidX so you may need to follow this guide.
https://developer.android.com/jetpack/androidx/migrate#migrate

Closing due to no response

Hello, I have exactly the same problem @jkasten2

I have followed the Google guide about how to set up a TWA: https://developers.google.com/web/updates/2019/02/using-twa (the com.github.GoogleChrome.custom-tabs-client:customtabs dependency is necessary for this).

It works great and then I want to integrate OneSignal into my TWA, so I add the OneSignal dependency in my build.gradle file and at this point it breaks because of these errors:

Duplicate class android.support.customtabs.BuildConfig found in modules classes.jar (com.android.support:customtabs:27.0.2) and classes.jar (com.github.GoogleChrome.custom-tabs-client:customtabs:809a55cfa2)
Duplicate class android.support.customtabs.CustomTabsCallback found in modules classes.jar (com.android.support:customtabs:27.0.2) and classes.jar (com.github.GoogleChrome.custom-tabs-client:customtabs:809a55cfa2)
... (and 9 others)

https://github.com/GoogleChrome/custom-tabs-client/blob/master/customtabs/build.gradle

dependencies {
    implementation 'com.android.support:support-v4:27.0.2'
    ...
}

https://github.com/OneSignal/OneSignal-Android-SDK/blob/master/OneSignalSDK/onesignal/build.gradle

dependencies {
    api 'com.android.support:support-v4:27.1.1'
    ...
}

Could it be reopened @rgomezp ? Is there a way to solve these duplication errors? Thanks.

Also the question could be asked like this: it is possible to use OneSignal in a TWA?

 implementation ('com.onesignal:OneSignal:3.12.7') {
      //  exclude group: "com.android.support", module: "support-v4"
        exclude group: "com.android.support", module: "customtabs"
    }

This will work :)

Help please)

build:gradle(:app)

plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.affil.dietcalculator"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
def map
map = manifestPlaceholders =[
        hostName       : "dietcalculator.tech",
        defaultUrl     : "https://dietcalculator.tech",
        launcherName   : "DietCalculator",
        assetStatements: '[{ "relation": ["delegate_permission/common.handle_all_urls"],' +
                '"target": {"namespace": "web", "site": "https://dietcalculator.tech"}}]'
]
map

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
implementation 'com.github.GoogleChrome:custom-tabs-client:a0f7418972'
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics-ktx'

and the error:
Duplicate class android.support.customtabs.ICustomTabsCallback found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub$Proxy found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.ICustomTabsService found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.ICustomTabsService$Stub found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.ICustomTabsService$Stub$Proxy found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.IPostMessageService found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.IPostMessageService$Stub found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.IPostMessageService$Stub$Proxy found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub$Proxy found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsCallback found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2$2 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2$3 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2$4 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsClient$2$5 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsIntent found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsIntent$Builder found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsService found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsService$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsService$Relation found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsService$Result found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsServiceConnection found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsServiceConnection$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsSession found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsSession$PendingSession found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsSessionToken found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsSessionToken$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.CustomTabsSessionToken$MockCallback found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.PostMessageService found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.PostMessageService$1 found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.PostMessageServiceConnection found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)
Duplicate class androidx.browser.customtabs.TrustedWebUtils found in modules browser-1.3.0-runtime (androidx.browser:browser:1.3.0) and jetified-customtabs-a0f7418972-runtime (com.github.GoogleChrome.custom-tabs-client:customtabs:a0f7418972)

Was this page helpful?
0 / 5 - 0 ratings