Add an “exclude module” rule to an entry in plugin.xml for Cordova

て烟熏妆下的殇ゞ 提交于 2019-12-01 21:45:59

Finally I resolved it, I had to create a build-extras.gradle file in my plugin containing the following lines:

configurations {
  all*.exclude group: 'com.android.support', module: 'support-v4'
  all*.exclude group: 'com.android.support', module: 'support-annotations'}

Then this gradle file need to imported in plugin.xml file using:

<framework src="build-extras.gradle" custom="true" type="gradleReference" />

I would highly recommend https://github.com/dpa99c/cordova-android-support-gradle-release which is a "plugin to align various versions of the Android Support libraries specified by other plugins".

They use a clever gradle dependency resolution to solve the problem:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group in ['com.android.support'] && !(details.requested.name in ['multidex', 'multidex-instrumentation'])) { details.useVersion "26.1.0"}
    }
}

This avoids the problem of removing all Android support libs, which can lead plugins having missing dependencies/failing gradle syncs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!