-2

I am trying to add brain tree services to my Unity app, as i need real item purchasing.

I am able to get the drop in ui working in a blank android project and created a module that handles it. However whenever i try to add the necessary aar file i get gradle build issues.

I have exported my project to android studio to get more comprehensive error codes and fine grained control over gradle.

However any configuration of gradle still gives me a Program type already present.

This is my the dependencies for my Gradle File

apply plugin: 'com.android.application'


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

implementation(name: 'android-maps-utils-0.5', ext:'aar')
implementation(name: 'google-maps-view-lib-release', ext:'aar')
implementation(name: 'play-services-base-11.0.2', ext:'aar')
implementation(name: 'play-services-basement-11.0.2', ext:'aar')
implementation(name: 'play-services-maps-11.0.2', ext:'aar')
implementation(name: 'play-services-tasks-11.0.2', ext:'aar')
implementation(name: 'support-compat-25.2.0', ext:'aar')
implementation(name: 'support-core-ui-25.2.0', ext:'aar')
implementation(name: 'support-core-utils-25.2.0', ext:'aar')
implementation(name: 'support-fragment-25.2.0', ext:'aar')
implementation(name: 'support-media-compat-25.2.0', ext:'aar')
implementation 'com.braintreepayments.api:braintree:2.20.0'


implementation ('com.braintreepayments.api:drop-in:3.2.1')

{
        exclude group: 'com.android.support.annotation'
        exclude module: 'com.android.support.v4.app'
        exclude module: 'com.android.support.v4.media'
        exclude module: 'com.android.support:support-v4:28.0.0'
        exclude group: 'support-v4'
        exclude module: 'support-v13'
    }
 //implementation(name: 'support-v4-25.2.0', ext:'aar')
}

What i get is:

Error: Program type already present: android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$1

shizhen
  • 12,251
  • 9
  • 52
  • 88

2 Answers2

0

Use below command to analyse your dependencies for the duplication.

./gradlew app:dependencies 

Noted that implementation 'com.braintreepayments.api:braintree:2.20.0' also depends on android.support.v4. So, try to exclude it also.

For the conflict dependencies version, you can specify the enforced version as below:

configurations.all {
    resolutionStrategy { 
        force "com.android.support:support-v4:26.0.0"
    }
} 
shizhen
  • 12,251
  • 9
  • 52
  • 88
0

Found a solution!

Just needed to edit the play services resolver to be adding in the braintree plugins rather than adding them manually or using gradle. It managed to seperate out all the individual components and resolve the conflicts!

Thanks for the responses tho.

I followed this solution Gradle dependencies on Unity.