Skip to content
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

Fonts not copied correctly with Android Gradle Plugin 4.1.0 #1265

Closed
2 tasks
mikehardy opened this issue Oct 21, 2020 · 2 comments · Fixed by #1307
Closed
2 tasks

Fonts not copied correctly with Android Gradle Plugin 4.1.0 #1265

mikehardy opened this issue Oct 21, 2020 · 2 comments · Fixed by #1307

Comments

@mikehardy
Copy link
Contributor

Environment

Android, android-gradle-plugin 4.1.0 (works fine with 4.0.2)

Description

Try to do a build with selective font inclusion:

./android/app/build.gradle

// Needed to shrink APK with react-native-vector-icons - don't include all the font files
project.ext.vectoricons = [
        iconFontNames: [ 'Entypo.ttf', 'FontAwesome.ttf' ] // Name of the react-native-vector-icons fonts to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
// End of react-native-vector-icons stuff

Reproducible Demo

Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve

I think this is similar to facebook/react-native#30177

@mikehardy
Copy link
Contributor Author

The problem is going to be somewhere in here but my gradle-fu is not quite strong enough to fix it:

currentFontTask.dependsOn("merge${targetName}Resources")
currentFontTask.dependsOn("merge${targetName}Assets")
[
"processArmeabi-v7a${targetName}Resources",
"processX86${targetName}Resources",
"processUniversal${targetName}Resources",
"process${targetName}Resources"
].each { name ->
Task dependentTask = tasks.findByPath(name);
if (dependentTask != null) {
dependentTask.dependsOn(currentFontTask)
}
}

gulshan183 pushed a commit to gulshan183/react-native-vector-icons that referenced this issue Nov 4, 2020
oblador#1265,Android Platform, Fonts not being copied if using Android gradle plugin 4.1.0 => FIXED
@gulshan183
Copy link

Currently, the creation and addition of tasks to the Task Graph are dependent upon the project to be evaluated while Gradle is building i.e gradle.projectsEvaluated. In simpler terms, This task is being created while the Gradle build is in the execution phase due to which the task to copy the fonts was not being added to the TaskGraph(of tasks to be executed).

Solution:
see: #1271
The listener to the project evaluated is now removed. Now, the tasks are added to the TaskGraph while in the configuration phase, thus our copy{}IconFonts task can be run in the execution phase of Gradle Build.

gulshan183 pushed a commit to gulshan183/react-native-vector-icons that referenced this issue Nov 6, 2020
mikehardy added a commit to mikehardy/react-native-vector-icons that referenced this issue Feb 12, 2021
- react-native JS bundle doesn't copy per-release target
- react-native JS bundle adds the copy task as dependent very carefully now!
- I added some metadata for the task, a "group" and "description"
- Fixed formatting, 4-space indents was predominant, I went with that everywhere

this is based heavily off the react-native JS bundle copy task
this was developed in collaboration with @gulshan183

Fixes oblador#1265
mikehardy added a commit to mikehardy/react-native-vector-icons that referenced this issue Feb 23, 2021
- react-native JS bundle doesn't copy per-release target
- react-native JS bundle adds the copy task as dependent very carefully now!
- I added some metadata for the task, a "group" and "description"
- Fixed formatting, 4-space indents was predominant, I went with that everywhere

this is based heavily off the react-native JS bundle copy task
this was developed in collaboration with @gulshan183

Fixes oblador#1265
oblador pushed a commit that referenced this issue Feb 23, 2021
)

- react-native JS bundle doesn't copy per-release target
- react-native JS bundle adds the copy task as dependent very carefully now!
- I added some metadata for the task, a "group" and "description"
- Fixed formatting, 4-space indents was predominant, I went with that everywhere

this is based heavily off the react-native JS bundle copy task
this was developed in collaboration with @gulshan183

Fixes #1265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants