Android - Fix Drawable v4 paths in Android Artifact Resources (Librar… #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation (required)
We've been attempting to package our React Native code into Library Dependencies (Cocoapods / Android Artifact Resource (aar)). Recently in React Native 0.42.0, there was an upgrade to the Android Project's gradle plugin from 1.3.1 to 2.2.3. This update drastically effected the outcome of drawable resources in Android without anyone noticing.
There are 4 outcomes to consider with this change:
With the upgrade to 2.2.3, Android changed the way aapt builds its resources. Any Library created with 2.2.3, has its resources ending with a
v4
suffix. The reasoning behind this I'm not sure of but assume it deals with Vector support that was added around that time.The change I've added checks if React Native is being ran in an Android Library vs an Application, and appends the v4 suffix to the merged asset folders.
Test Plan (required)
Multiple test were performed.
I first started out validating my assumption about the asset merger by creating a new Android Project to verify my assumptions above.
i. Application + >= 2.2.3 -- hdpi contains my drawable. hdpi-v4 contains dependency's drawables.
ii. Application + <= 1.3.1 -- Same as above (I expect because deps are compiled against gradle 2.2.3+ themselves.
iii. Library + >= 2.2.3 -- Only -v4 folders found! Resources from the library are packages in the app's build output in similar -v4 folder too.
iv. Library + <= 1.3.1 -- Same as ii. & iii. -v4 contains other resources, but my resources are located in non -v4 folder.
I then wanted to validate against React Native itself. So I updated my react native code using this PR/Branch, and tested against my project locally. Unfortunately I cannot share that code as it is private, but before this change I was getting the same error as mentioned in gradlew assembleRelease failing at processReleaseResources [0.19] facebook/react-native#5787 and now my build runs as intended with the assets being placed where they should be.
Additional resources:
http://stackoverflow.com/questions/35700272/android-build-tool-adds-v4-qualifier-to-drawable-folders-by-default-in-generated