I have a android library with com.android.support:appcompat-v7:23.0.1
dependency in the gradle with compliedSDK of 23
I have following doubts
case 1) Say any applicaion with different version com.android.support:appcompat-v7:23.3.0
uses my library.
- which version does the android take? Lower one or Higher one? How do i see it?
- How do i make sure there is no conflict of v7 appcompat when any app uses my library?
case 2) Say any applicaion with different version com.android.support:appcompat-v7:25.0.1
or com.android.support:appcompat-v7:24+
and different compiledSDk(24 or 25) uses my library.
I know that The support library should not use a different version than the compileSdkVersion
.
- How does the android merge the support libraries now? (Since the support library version(
appcompat-v7:23.0.1
) of my library is different from that of the application's compiledSDK (25) ) - How do i make sure there is no conflict of v7 appcompat when any app uses my library?
Anyone Please clear my doubts
- which version does the android take? Lower one or Higher one? How do i see it?
When building library you put the dependency explicitly in build.gradle
. The same is done by the creator of app, that uses your library as a dependency declared in his build.gradle
. If the creator explicitly declares support library as a dependency, that version is taken (regardless the versions declared by dependencies). If he does not do that, the highest version declared by any dependency is taken (such support library is regarded as a transitive dependency).
Example: Your library uses appcompat-v7:23.3.0
. The creator of app declared appcompat-v7:25.0.1
. Simple case: appcompat-v7:25.0.1
is taken.
Example 2: Your library uses appcompat-v7:23.3.0
. The creator of app does not use appcompat-v7
. appcompat-v7:23.3.0
will be in output app.
Example 3: Your library uses appcompat-v7:23.3.0
. Another library uses appcompat-v7:24.1.0
. If the creator does not explicitly declare appcompat-v7:xx.x.x
the version appcompat-v7:24.1.0
will be in output app.
Hope you understand.
- How do i make sure there is no conflict of v7 appcompat when any app uses my library?
You can't assure that. That is why you should always put the highest version of support libraries in the library. I can't even assure you the support libraries maintain backward compatibility. Here is the example that they don't.
I know that The support library should not use a different version than the compileSdkVersion.
That is only a suggestion. However, you should conform to it, but you don't have to.
来源:https://stackoverflow.com/questions/40859766/how-does-android-merge-the-custom-librarys-support-library-with-that-of-applica