1

I use the NativeScript plugin Firebase and the NativeScript plugin WonderPush. But when I try to compile for Android, I get an error :

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[11.0.4,11.0.4], [15.0.1,15.0.1]], but resolves to 15.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

I think it's because Firebase plugin uses version 15.0.1 of the library while WonderPush uses version 11.0.4.

How can I fixed this conflict into my project? (I can't modify these plugins)

Thanks

ofavre
  • 4,488
  • 2
  • 26
  • 23

1 Answers1

2

The way to solve this is to add a section to your app.gradle file in your app/app_resources/android folder.

Your default one probably looks like this:

// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
//  compile 'com.android.support:recyclerview-v7:+'
//}

android {  
  defaultConfig {  
    generatedDensities = []
    applicationId = "__PACKAGE__" 

    //override supported platforms
    // ndk {
    //       abiFilters.clear()
    //          abiFilters "armeabi-v7a"
        // }

  }  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
} 

Change it to look like this:

dependencies {
    configurations.all {
        exclude group: 'commons-logging', module: 'commons-logging'
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.google.android.gms' || requested.group == 'com.google.firebase') {
                details.useVersion '15.0.1'
            } else if (requested.group == 'com.android.support' && requested.name != 'multidex') {
                // com.android.support major version should match buildToolsVersion
                details.useVersion '27.+'
            }
        }
    }
}

project.ext {
    googlePlayServicesVersion = "15.0.1"
    supportVersion = "27.+"
}

android {
      defaultConfig {  
        generatedDensities = []
        applicationId = "__PACKAGE__"               
      }  
      aaptOptions {  
        additionalParameters "--no-version-vectors"  
      }  
    project.ext {
        googlePlayServicesVersion = "15.0.1"
        supportVersion = "27.+"
    }
}

This should force Gradle to use 15.0.1 to be used for both plugins...

Nathanael
  • 5,369
  • 18
  • 23