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

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

Open
aerielcruz opened this issue Feb 7, 2024 · 5 comments

Comments

@aerielcruz
Copy link

aerielcruz commented Feb 7, 2024

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
Copy link
Author

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
Copy link

@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

@nassimerrahoui
Copy link

nassimerrahoui commented Dec 9, 2024

Is there any possibilty that we can configure a build.gradle (from app folder) file, from an app.config.ts file in futher versions of Expo ?

For example, if we want to modify stuff like :

  • manifestPlaceholders
  • compileOptions
  • kotlinOptions
  • dependencies

Seems like using config plugins for that is a little bit dirty and risky.

@anhtuan219
Copy link

@nassimerrahoui For some build configuration (e.g. minSdkVersion, targetSdkVersion, compileSdkVersion, kotlinVersion, buildToolsVersion, deploymentTarget,...) you can use expo-build-properties
But if you want more granular control, until now the most suitable solution that I can found is to use config plugins

@nassimerrahoui
Copy link

nassimerrahoui commented Dec 9, 2024

@anhtuan219 Thank you for your help. For the moment, it is more easy for me to maintain a bare workflow just on Android to add those configuration. Especially to add a native dependency for instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants