Home > Net >  Add a gradle repository to an expo app build with eas build / managed workflow
Add a gradle repository to an expo app build with eas build / managed workflow

Time:07-20

I have the following...

Situation:

I have a react native app (lets call it "MyApp") build on the expo platform. I use eas build to build the project.

Lately I forked the expo-camera package to update the iOS part to be able to use the ultra wide camera. For now I left the android part untouched. I uploaded my fork to the npm-registry as myApp-expo-camera and updated the dependency in MyApp from expo-camera to myApp-expo-camera

Error:

Now when I build iOS it all works as expected, but when I build android it tells me, that it is missing the cameraview package:

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android:cameraview:1.0.0.
     Required by:
         project :app > project :expo > project :expo-camera

Problem:

This cameraview package comes with the expo-camera as an .aar archive. The README.md in expo-camera says for the installation in a managed expo project to use expo install expo-camera which is no solution for me since I want to use my fork.

For the installation in a bare react native project it says to add the following to the build.gradle:

allprojects {
    repositories {

        // * Your other repositories here *

        // * Add a new maven block after other repositories / blocks *
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}

As far as I understand I can use "none expo" third party react native packages since I'm using eas build but I can not add this to the build.gradle because I'm still in the managed workflow of expo (and therefor do not even have a build.gradle file).

Does anybody have an idea on how to solve this situation?

Sincerely

CodePudding user response:

It happens, that I found the solution to my problem. So for everybody with a similar problem:

The expo-camera package has a file withCamera.ts in the plugin directory. This file contains logic, that writes the needed line of build.gradle code into the build.gradle of your actual / own project. But for this to work you need to run the forked expo-camera package in the prebuild section of the eas build workflow. This can be achived by adding the following to the app.json / app.config.js in your own expo-project:

plugins: ['myApp-expo-camera'],

With this line the eas build process knows, that your myApp-expo-camera needs to be prebuild.

Also make sure, that you have adjusted the packagename in the withCamera.ts file to your fork (e.g. myApp-expo-camera).

What I still don't understand is: Why would you not need to do that for the original expo-camera package... but maybe expo has all their own packages already in a prebuild config... who knows!

  • Related