1

我使用 NativeScript 插件Firebase和 NativeScript 插件WonderPush。但是当我尝试为 Android 编译时,我得到一个错误:

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.

我认为这是因为 Firebase 插件使用版本 15.0.1 的库,而 WonderPush 使用版本 11.0.4。

我怎样才能在我的项目中解决这个冲突?(我无法修改这些插件)

谢谢

4

1 回答 1

1

解决这个问题的方法是在 app/app_resources/android 文件夹中的 app.gradle 文件中添加一个部分。

您的默认设置可能如下所示:

// 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"  
  }  
} 

将其更改为如下所示:

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.+"
    }
}

这应该强制 Gradle 使用 15.0.1 来用于两个插件...

于 2018-07-27T20:34:27.457 回答