-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android - Fix Drawable v4 paths in Android Artifact Resources (Libraries) #13128
Conversation
* master: (161 commits) Use the absolute path to the sourcemap in the CS bundle packager: index files by dir for fast matching Revert D4840716: Refactor interfaces packager: GlobalTransformCache: make key globalized Check that RCTDidInitializeModuleNotification is being called with the correct bridge Refactor interfaces Report JS errors in debug console Apple TV documentation Move away from rnplay to snack, with embedded examples! use performanceNow instead of Date.now() in ScrollResponder Deploy v0.43.0 Removed some no-longer-necessary Flow ignores. Update Keyboard.js configurable devEnabled in React.gradle Use tag ids for testID Update IntegrationWithExistingApps.md Update docs to clarify `RCT_REMAP_METHOD` usage. Enable flow in react-native-implementation Improve z-index implementation on Android Remove the dependency of I18nManagerModule on ReactApplicationContext ...
@vonovak @AndrewJack Would you be able to review? I noticed both of you as the most recent to edit/review this file in git. |
@jpshelley I don't understand drawables, but just wondering - why you use |
Does this only occur when applying the script to a library project? This script was made to support Applications ( Do you have a sample project that reproduces this issue? |
@AndrewJack From what I've gathered, it is only happening on Library Projects, that is correct. At Hudl we are taking a similar approach as Artsy and compiling our React Native code into a Library Project that can be imported into our main native apps, in order to minimize friction. In the Test Plan I have already created 4 separate projects that show the Android build outputs for drawables to back up my claims. I can create a sample react native project that demonstrates this later today and will comment back when I have them done. |
Sorry for the delay @AndrewJack here are the following:
Project 4 is the only one that doesn't work. Its due to the bundler (which can be ran on any commit to verify) and the upgrade of Gradle which mismatches Android Library's declared drawable folder name. |
@AndrewJack keen to see this PR merged - will make my dev much less painful! |
Why not just copy Your use case seems fairly uncommon so I'd hesitate including these changes. |
@AndrewJack We could do that, but then if |
Its been over a month, is there any remaining issues with this PR? Can it be merged? |
+1 |
@jpshelley I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
@jpshelley I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
@facebook-github-bot label Needs more information Generated by 🚫 dangerJS |
@jpshelley I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Generated by 🚫 dangerJS |
@jpshelley I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Could we please merge this? 🙃
|
(@jpshelley There's a merge conflict now) |
@jpshelley I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Thanks for the PR! @facebook-github-bot shipit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satya164 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
…ies) Summary: _Quick apologies for the lengthiness of this description. Want to make sure I'm clear and it is understood what is being altered._ Thanks for submitting a PR! Please read these instructions carefully: - [x] Explain the **motivation** for making this change. - [x] Provide a **test plan** demonstrating that the code is solid. - [x] Match the **code formatting** of the rest of the codebase. - [x] Target the `master` branch, NOT a "stable" branch. facebook#5787 ``` Unknown source file : /home/tom/projects/blueprint-native/android/app/build/intermediates/res/merged/release/drawable-mdpi-v4/images_google.png: error: Duplicate file. Unknown source file : /home/tom/projects/blueprint-native/android/app/build/intermediates/res/merged/release/drawable-mdpi/images_google.png: Original is here. The version qualifier may be implied. ``` At Hudl, 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:** 1. You are developing in an Android Application using Gradle 1.3.1 or lower 2. You are developing in an Android Application using Gradle 2.2.3 or higher 3. You are developing in an Android Library Module using Gradle 1.3.1 or lower 4. You are developing in an Android Library Module using Gradle 2.2.3 or higher 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. Multiple test were performed. 1. I first started out validating my assumption about the asset merger by creating a new Android Project to verify my assumptions above. 1. [Application + >= 2.2.3](https://github.com/jpshelley/TestAndroidLibraryDrawables/tree/master/app/build/intermediates/res/merged/debug) -- `hdpi` contains my drawable. `hdpi-v4` contains dependency's drawables. 2. [Application + <= 1.3.1](https://github.com/jpshelley/TestAndroidLibraryDrawables/tree/Android-LegacyVersion/app/build/intermediates/res/merged/debug) -- Same as above (I expect because deps are compiled against gradle 2.2.3+ themselves. 3. [Library + >= 2.2.3](https://github.com/jpshelley/TestAndroidLibraryDrawables/tree/Android-UsingAndroidLibrary/library/build/intermediates/res/merged/debug) -- Only `-v4` folders found! Resources from the library are packages in the app's build output in similar `-v4` folder too. 4. [Library + <= 1.3.1](https://github.com/jpshelley/TestAndroidLibraryDrawables/tree/Android-UsingAndroidLibraryLegacyVersion/library/build/intermediates/res/merged/debug) -- Same as ii. & iii. `-v4` contains other resources, but my resources are located in non -v4 folder. 2. 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 facebook#5787 and now my build runs as intended with the assets being placed where they should be. Additional resources: * facebook#5787 * http://stackoverflow.com/questions/35700272/android-build-tool-adds-v4-qualifier-to-drawable-folders-by-default-in-generated * facebook#12710 Please let me know if more information is needed, further test plans, etc. With this change we should be able to upgrade to Gradle 2.3.0 as well to support the latest version of Android Studio. Closes facebook#13128 Differential Revision: D7828618 Pulled By: hramos fbshipit-source-id: a7ad7b63b1b51cbfd2ea7656e4d77321306ce33a
Quick apologies for the lengthiness of this description. Want to make sure I'm clear and it is understood what is being altered.
Thanks for submitting a PR! Please read these instructions carefully:
master
branch, NOT a "stable" branch.Motivation (required)
#5787
At Hudl, 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.
hdpi
contains my drawable.hdpi-v4
contains dependency's drawables.-v4
folders found! Resources from the library are packages in the app's build output in similar-v4
folder too.-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] #5787 and now my build runs as intended with the assets being placed where they should be.
Additional resources:
Please let me know if more information is needed, further test plans, etc. With this change we should be able to upgrade to Gradle 2.3.0 as well to support the latest version of Android Studio.