expo / fyi

Little bits of information that you may find useful when interacting with Expo tools and service. Append the markdown filename to https://expo.fyi/ to get a quick link to it.
794 stars 344 forks source link

How to patch expo module build.gradle file for a managed expo workflow? #147

Open aerielcruz opened 9 months ago

aerielcruz commented 9 months ago

Gradle 8 Migration for Custom Expo Modules https://github.com/expo/fyi/blob/main/expo-modules-gradle8-migration.md#error-task-current-target-is-17-and-compilereleasekotlin-task-current-target-is-11-jvm-target-compatibility-should-be-set-to-the-same-java-version

It says that you have to patch the build.gradle file of the expo module but am I supposed to edit it from node_modules?

An example would be expo-splash-screen

* What went wrong:
A problem occurred evaluating project ':expo-splash-screen'.
> Could not set unknown property 'classifier' for task ':expo-splash-screen:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.

This issue only happens for Android and not iOS.

aerielcruz commented 9 months ago

Fixed it! 🥳 This is what I did

  1. I started to run this command to see the relation of expo-splash-screen (replace this with the expo module)
    npm why expo-splash-screen
  2. This is the result
    expo-splash-screen@0.17.5
    node_modules/expo-splash-screen
      expo-splash-screen@"~0.17.0" from expo-app-loading@2.1.1    
      node_modules/expo-app-loading
        expo-app-loading@"~2.1.1" from the root project
  3. I checked expo-app-loading and it is a deprecated package
  4. I uninstalled expo-app-loading, build again and voila problem solved! 😄

Even this solved my issue, I still want to know how to update the build.gradle file for a managed workflow.

anhtuan219 commented 3 weeks ago

@aerielcruz You can use config plugin to modify the native files for a managed workflow Here's an example that modifies file /android/app/build.gradle If you want to modify file /android/build.gradle, use withProjectBuildGradle from @expo/config-plugins instead