【问题标题】:Nativescript conflict between two plugins - Android gradle两个插件之间的Nativescript冲突 - Android gradle
【发布时间】:2018-07-27 13:21:36
【问题描述】:

我使用 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 版本。

如何在我的项目中解决这个冲突? (我无法修改这些插件)

谢谢

【问题讨论】:

    标签: android gradle nativescript wonderpush


    【解决方案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 用于两个插件...

    【讨论】:

      猜你喜欢
      • 2011-03-10
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多