Unable to use native modules with EAS build

We noticed that with EAS build, we could use some non-expo-included react-native modules,
there is one module that we need to use in our project called “react-native-minimizer”
it provides a native function called NativeModules.Minimizer for app to navigate back last app or minimize in Android or iOS

But now after I installed the react-native package and build our app by eas build, the module was not functioned.
-We are using EAS build by command “eas build --profile=development -p ios --non-interactive”, I think it is managed flow ?
-We just installed the package by “yarn add react-native-minimizer”, without any other command
-We are using eas-cli@2.6.0, and the node version is 16.15.0

To use a third-party lib it needs to have a config plugin that configures it for expo, or there is no native setup necessary to make it work other than yarn add and pod install

As for the package react-native-minimizer

  • there is no git repo(or it’s private)
  • readme here does not make sense react-native-minimizer - npm
  • readme on older version contains instructions for native config react-native-minimizer - npm If you want to use that, you would need to write config plugin yourself or switch to bare workflow

Thanks for advice, may I ask you how to make a config plugin to configure it for expo ? Can I do this by myself ?

That depends on what you would need to do for a plain React Native project to install the module.

Where are you getting it from? According to the description of the react-native-minimizer module on npm (see wkozyra’s message) it only exports a multiply function. It links to a non-existent GitHub project. It does not seem very trustworthy to me.

Based on the installation instructions in the older version you just need a config plugin to add the maven URL to the build.gradle file. I am not an expert on build.gradle, though, so I don’t know exactly what that line does. It seems like it would be looking for a filesystem directory rather than a maven repository on the Internet, so I’m not sure if it would find the directory. But if you trust this module you could try it and see.

This is the documentation on writing config plugins: Config Plugins - Expo Documentation

But you might find it easier to look for existing config plugins to find one that does something similar to what you do and then use those as a guide for writing your own.

e.g.:

1 Like

Can you give me some advices about how to use bare workflow to use this plugin ?

this is another open sourced branch of this library, may I ask you to checkout if this is needed to create a config plugin?

OK, so that looks like a very simple module.

It’s basically just the following:

The rest is all boilerplate or unused. This is an Android-only module. The iOS code is just sample code and so is the “multiply” documentation.

I had a bit of a search and could not find moveTaskToBack or equivalent in React Native or e.g. React Navigation.

In theory you should be able to implement minimize using IntentLauncher, but I gave it a try and was not able to get it to work properly. If you want to give it a try it would be something like this:

import { startActivityAsync } from 'expo-intent-launcher';

async function minimize() {
  await startActivityAsync('android.intent.action.MAIN', {
    category: 'android.intent.category.HOME',
    flags: 0x00008000,
  });
}

export default function App() {
  return (
    <View style={styles.container}>
      <Button title="Minimize" onPress={() => minimize()} />
    </View>
  );
}

But if you want to use coder89/react-native-minimizer then it looks like it should work without the need of a config plugin or anything special. You would just need to create a development build and then use the development build instead of Expo Go.

Perhaps the problem is with how you are importing or calling the minimize function.

Try something like:

import { goBack, minimize } from "react-native-minimizer";

// ...

minimize();

Thank you very much! I’ll give a try

Try something like:

import { goBack, minimize } from "react-native-minimizer";

// ...

minimize();

While I import the methods by this way and rebuild a development build by EAS,

I got a crash on calling “minimize” … The app just crashed to iOS homepage with no other feedback

As I said previously, react-native-minimizer is an Android-only module. It will not work on iOS.

On iOS it only has sample code implementing a multiply function.

may I ask you to help checkout on version 1.3.5 iOS folder, it is much different from 1.3.6

I installed 1.3.5 and imported it as the methods above, no crash but no any other effects too.

Thanks!

The reason why I need to use this library is to navigate back to last app as I tap a button like “{{lastapp}}>” on the left-top of iOS screen.

Seems like there is no library to provider this function but this “react-native-minimizer”

The iOS code from version 1.3.5 looks more promising, yes.

I’m afraid you will need to contact the authors of that library to ask about it if it doesn’t work.
It sounds like you are able to build the app successfully and you are able to call it. If it doesn’t work then it sounds like a bug in that library and you’ll have to contact them about it.

2 Likes

Thank you, helped me a lot !

1 Like