We are maintaining an Android Library. Lately we upgraded gradle, compileSdkVersion and support library versions. (only using com.android.support:design). Also we upgraded gcm-play-services The library is published to Artifactory with its dependencies also in a pom file. This upgrade works perfectly on projects with upto-date build tools and support libraries. However we are facing an issue with outdated projects that uses our library. Here is the versions of library.
gradle android plugin -> 3.2.1
compileSdkVersion -> 28
targetSdkVersion -> 28
support library version -> 28.0.0
Here is the versions of project
compileSdkVersion -> 26
targetSdkVersion 26
support library version -> 26.0.1
and client support library dependencies
implementation 'com.android.support:cardview-v7:' + androidSupportV
implementation 'com.android.support:recyclerview-v7:' + androidSupportV
implementation 'com.android.support:appcompat-v7:' + androidSupportV
implementation 'com.android.support:design:' + androidSupportV
implementation 'com.android.support:support-v4:' + androidSupportV
implementation 'com.android.support:support-annotations:28.0.0'
after trying to build the project with new library, build fails with this log.
AGPBI: {"kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":[{"file":"/Users/umutyusuf/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/d4439e502685c256006fa4bec8edb713/res/values-v28/values-v28.xml","position":{"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":[{"file":"/Users/umutyusuf/Documents/repo/core-bootstrap/core-android-client-app/PointrSample-Ozion-v5.0.8/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml","position":{"startLine":10}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/fontVariationSettings not found.","sources":[{"file":"/Users/umutyusuf/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/d4439e502685c256006fa4bec8edb713/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/ttcIndex not found.","sources":[{"file":"/Users/umutyusuf/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/d4439e502685c256006fa4bec8edb713/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
We avoid to do any manipulations in project code, so tried to solve it in library.
We downgrade the all versions to match the project versions. And published it with again with
compileSdkVersion -> 26
targetSdkVersion 26
support library version -> 26.0.1
But after that, we face a manifest merge error
Error:
Attribute meta-data#android.support.VERSION@value value=(26.0.1) from [com.android.support:cardview-v7:26.0.1] AndroidManifest.xml:25:13-35
is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override
This is originated from gcm-play-services which has support-v4:26.1.0 transitive dependency listed in dependency tree.
and to resolve it, added this to manifest
<meta-data
tools:node="replace"
tools:replace="android:value"
android:name="android.support.VERSION"
android:value="26.0.1" />
This made it all work. But now what would be the drawbacks of putting this meta tag to AndroidManifest file?
We tested this approach with all of compileSdkVersion 26, 27, 28 and all corresponding support library version. All seem to work.
We are search for better approaches to this.
Alternative solution we tried
We published the support library dependency in provided scope. But in this case projects using library should add their support design library to be able to use the with no problem. But even though they add the support library, would it be a problem if project had different support library version other then what library is compiled with?