[英]What happens if two android modules of the same android project use different support library versions?
I have an android project with two modules. 我有一个带有两个模块的android项目。 I already have released this app to Google Play.
我已经将该应用发布到了Google Play。 Today I found that these two modules have used different support library version dependencies in their gradle files (in the version currently in production in Google Play).
今天,我发现这两个模块在其gradle文件中使用了不同的支持库版本依赖性(在Google Play当前正在生产的版本中)。
Can having different support library versions in app modules cause unexpected problems? 应用程序模块中具有不同的支持库版本是否会导致意外问题?
If there is a version conflict, gradle will automatically select the highest version available. 如果存在版本冲突,gradle将自动选择可用的最高版本。 Imagine an app project 'app' that includes a library module 'mylibrary'.
想象一个应用程序项目“ app”包含一个库模块“ mylibrary”。 I have set the compat lib version to 23.2.1 in 'app' and 23.2.0 in 'mylibrary'.
我已经在“ app”中将compat lib版本设置为23.2.1,在“ mylibrary”中将其设置为23.2.0。 The output of
./gradlew :app:dependencies
shows which one gets selected in the end: ./gradlew :app:dependencies
的输出显示最后选择了哪个:
_debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:23.2.1
| +--- com.android.support:support-v4:23.2.1
| | \--- com.android.support:support-annotations:23.2.1
| +--- com.android.support:animated-vector-drawable:23.2.1
| | \--- com.android.support:support-vector-drawable:23.2.1
| | \--- com.android.support:support-v4:23.2.1 (*)
| \--- com.android.support:support-vector-drawable:23.2.1 (*)
+--- com.android.support:recyclerview-v7:23.2.1
| +--- com.android.support:support-v4:23.2.1 (*)
| \--- com.android.support:support-annotations:23.2.1
+--- com.android.support:design:23.2.1
| +--- com.android.support:support-v4:23.2.1 (*)
| +--- com.android.support:appcompat-v7:23.2.1 (*)
| \--- com.android.support:recyclerview-v7:23.2.1 (*)
+--- com.android.support:percent:23.2.1
| \--- com.android.support:support-v4:23.2.1 (*)
\--- project :mylibrary
\--- com.android.support:appcompat-v7:23.2.0 -> 23.2.1 (*)
Notice the very last line where the compat lib for mylibrary gets upgraded to from 23.2.0 to 23.2.1. 请注意最后一行,用于库的compat lib从23.2.0升级到23.2.1。 This will happen for any library with the same group and name components.
具有相同组和名称组件的任何库都将发生这种情况。
Yes, there can be problems when a version gets upgraded like this. 是的,这样升级版本时可能会出现问题。 If the changed version of the library is not backward compatible with the prior version, the code that references the older version might fail to compile with missing methods.
如果库的更改版本与先前版本不向后兼容,则引用较旧版本的代码可能会因缺少方法而无法编译。 For micro and minor version update, this is typically not a problem, but for major version updates it can be.
对于微型和次要版本更新,这通常不是问题,但是对于主要版本更新则可以。 It completely depends on the specific situation.
这完全取决于具体情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.