EAS android build fails: A problem occurred evaluating project ':react-native-zohosalesiq-mobilisten'

Hi, we have recently integrated the react-native-zohosalesiq-mobilisten package. This package adds online chat with in the app and links to our zoho CRM. Our app is a managed workflow through expo and using a development build we are able to successfully build and run our app with this package on iOS, which is awesome.

Unfortunately this does not work for our android build. Here is the output:

[stderr] FAILURE: Build failed with an exception.
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/node_modules/react-native-zohosalesiq-mobilisten/android/build.gradle' line: 40
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':react-native-zohosalesiq-mobilisten'.
[stderr] > Could not find method compile() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 3m 28s

After Googling for a bit I attempted to change the compile method to implementation using a fork of the react-native-zohosalesiq-mobilisten repo, all this fork does is literally change the compile to implementation in the build.gradle file but this still fails.

Is there a way I can update the build.gradle file in a managed workflow using expo-build-properties? Is anyone else using the native-zohosalesiq-mobilisten in their expo project?

Another area I feel it might be breaking is covered in step 3 of the installation guide by zoho. Specifically adding maven { url 'https://maven.zohodl.com' } to the repositories section of the build.gradle. Does the development build handle this or do I have to do additional config within my managed workflow?

SDK version 45
eas-cli 1.1.1

I will add package.json and other configs on request. Thanks for your help!

Hi @roundups

I see they have made that same change themselves, amongst other things. So you should try upgrading it.

No, that is something that will have to be done with a Config Plugin. Either react-native-zohosalesiq-mobilisten will have to write it, or you will.

Fortunately you should be able to use the following Config Plugin as a template:

1 Like

Good spot on the change! Don’t know how I missed that.

I will attempt my own plugin and feedback. Thanks for your timely response.

Hi @wodin, I have attempted to create a custom plugin and made minor success. Here is my plugin code:

import { withProjectBuildGradle } from '@expo/config-plugins';
import {
  createGeneratedHeaderComment,
  removeGeneratedContents,
} from '@expo/config-plugins/build/utils/generateCode';

const gradleMaven = `allprojects { repositories { maven { url 'https://maven.zohodl.com' } } }`;

function appendContents({ src, newSrc, tag, comment }) {
  const header = createGeneratedHeaderComment(newSrc, tag, comment);
  if (!src.includes(header)) {
    // Ensure the old generated contents are removed.
    const sanitizedTarget = removeGeneratedContents(src, tag);
    const contentsToAdd = [
      // @something
      header,
      // contents
      newSrc,
      // @end
      `${comment} @generated end ${tag}`,
    ].join('\n');

    return {
      contents: sanitizedTarget ?? src + contentsToAdd,
      didMerge: true,
      didClear: !!sanitizedTarget,
    };
  }
  return { contents: src, didClear: false, didMerge: false };
}

function addSalesIQImport(src) {
  return appendContents({
    tag: 'salesIQ',
    src,
    newSrc: gradleMaven,
    comment: '//',
  });
}

module.exports = function withSalesIQ(config) {
  return withProjectBuildGradle(config, config => {
    if (config.modResults.language === 'groovy') {
      config.modResults.contents = addSalesIQImport(
        config.modResults.contents,
      ).contents;
    } else {
      throw new Error(
        'Cannot add SalesIQ maven gradle because the build.gradle is not groovy',
      );
    }
    return config;
  });
};

I lifted most of this from the expo-camera example and updated the maven line as necessary for my package. I import this as a plugin in my plugins array in my app.json. When I try to run eas build --profile production -p android I receive this error:
SyntaxError: Cannot use import statement outside a module

I haven’t been able to fix after some googling and I’m a little confused as it is very similar to your example.

Could you provide some feedback on my implementation and the error please. Thanks for your help!

Sorry, I should have mentioned. The example is written in TypeScript. I’m not quite sure what you need to do to use TypeScript config plugins, but I suppose you have to compile it.

If your app is in plain JavaScript, you can use JavaScript for the config plugin, but you’ll need to use require instead of import.

See the following for an example:

Hi @wodin, thanks for your reply.

Annoyingly I did update the script to work with require but didn’t attempt to build as the eslint error put me off :man_facepalming: It has since built successfully and I can confirm the package works in android.

Thanks for your support, I feel like I’ve gained a superpower now!

For those who might need the code, all I changed from the above is the import statements to require statements:

const { withProjectBuildGradle } = require('@expo/config-plugins');
const {
  createGeneratedHeaderComment,
  removeGeneratedContents,
} = require('@expo/config-plugins/build/utils/generateCode');

I consider this matter resolved now, cheers.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.