简体   繁体   English

如果同一android项目的两个android模块使用不同的支持库版本会怎样?

[英]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.

相关问题 如何通过Gradle使Android Studio中的两个不同模块使用同一库的不同版本 - How to make two different modules in Android Studio use different versions of the same library via Gradle 两个模块在Android Studio中使用相同的库 - Two modules use same library in Android Studio 如何强制android studio为项目和库使用不同的库版本 - How to force android studio to use different library versions for project and library 在jar库中支持不同的Android版本 - Support different Android versions in a jar library 同一个项目使用不同版本的分页库 - Use different versions of paging library in the same project 在同一个Android项目中使用不同版本的Firebase和Google Play服务? - Use different versions of Firebase and Google Play Services in same Android project? 两个依赖项使用相同的库但具有不同的版本 - Two dependencies use the same library but with different versions 在同一个项目中使用多个模块来维护一个应用Android Studio的两个版本 - Using multiple modules in same project to maintain two versions of an app Android Studio 如何在不同的Android Studio模块中使用相同gradle依赖项的不同版本? - How to use different versions of the same gradle dependency in different Android Studio modules? 查看两个版本之间Android支持库源代码的更改 - See changes in Android Support Library sources between two versions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM