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

A problem was found with the configuration of task ':expo-constants:copyDebugExpoConfig' #4220

Open
1 of 2 tasks
talaikis opened this issue Oct 16, 2023 · 7 comments
Open
1 of 2 tasks

Comments

@talaikis
Copy link

What happened?

./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release for react-native 0.72 + expo 49:

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':expo-constants:copyDebugExpoConfig' (type 'Copy').
  - Gradle detected a problem with the following location: 'C:\Users\DXenu\Desktop\Weido\weido-dev\node_modules\expo-constants\android\src\main\assets'.

    Reason: Task ':expo-constants:packageReleaseAssets' uses this output of task ':expo-constants:copyDebugExpoConfig' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':expo-constants:copyDebugExpoConfig' as an input of ':expo-constants:packageReleaseAssets'.
      2. Declare an explicit dependency on ':expo-constants:copyDebugExpoConfig' from ':expo-constants:packageReleaseAssets' using Task#dependsOn.
      3. Declare an explicit dependency on ':expo-constants:copyDebugExpoConfig' from ':expo-constants:packageReleaseAssets' using Task#mustRunAfter.

What was the expected behaviour?

Successful test build.

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: 20.13.0
React Native version: 0.72.5
Has Fabric (React Native's new rendering system) enabled: no
Node version: 20.7.0
Device model: -
Android version: 33
Test-runner -

Detox logs

No response

Device logs

No response

More data, please!

No response

@noomorph
Copy link
Collaborator

@talaikis , sorry, our Android guys are unavailable, so the best I can do for you at the moment is to involve ChatGPT. Please read its response and see if its blind guess is applicable to your android/** folder and its contents. I tend to agree that something needs to be fixed in Gradle files, but I don't have enough information to locate that exact spot.

🤖 ChatGPT says:


The error seems to be related to a misconfiguration between Gradle tasks in the expo-constants library when trying to assemble a release build. Let's go step-by-step to solve this issue:

1. Diagnosing the Problem:

The error message you provided gives valuable information about the problem:

Reason: Task ':expo-constants:packageReleaseAssets' uses this output of task ':expo-constants:copyDebugExpoConfig' without declaring an explicit or implicit dependency.

It suggests that the task :expo-constants:packageReleaseAssets is relying on the output of the :expo-constants:copyDebugExpoConfig task, but there's no explicit or implicit dependency declared. In other words, Gradle might run the tasks out of order, which could lead to the failure you're seeing.

2. Potential Solutions:

The error message provides a few suggested solutions. Let's break each one down:

  1. Declare task :expo-constants:copyDebugExpoConfig as an input of :expo-constants:packageReleaseAssets. This would make sure that the output of the former task is always up-to-date when the latter task runs.

  2. Declare an explicit dependency on :expo-constants:copyDebugExpoConfig from :expo-constants:packageReleaseAssets using Task#dependsOn. This would make sure that the copyDebugExpoConfig task always runs before the packageReleaseAssets task.

  3. Declare an explicit dependency on :expo-constants:copyDebugExpoConfig from :expo-constants:packageReleaseAssets using Task#mustRunAfter. This is similar to the previous solution but provides a softer guarantee. It suggests a preferred order but doesn't enforce it strictly.

3. Applying the Fix:

For the sake of reliability, we'll go with the second solution as it ensures a strict order of execution. To do this:

  1. Navigate to the build.gradle file of the expo-constants module in your node_modules directory: node_modules/expo-constants/android/build.gradle.

  2. Find the :expo-constants:packageReleaseAssets task definition.

  3. Add a dependency on the :expo-constants:copyDebugExpoConfig task:

task packageReleaseAssets(type: SomeType) {
    // ... existing configuration ...

    dependsOn ':expo-constants:copyDebugExpoConfig'
}

Replace SomeType with the actual type of the task, if it's already defined.

  1. Save the file and try to run the failing command again.

4. Permanent Fix:

The above solution is a temporary fix since it directly modifies the code inside node_modules, which can be overridden on the next npm install or yarn install. For a permanent solution:

  1. Consider creating a patch using patch-package to apply the fix after each npm install.

  2. Alternatively, report this issue to the maintainers of the expo-constants library (if it hasn't been reported already) so they can address it in a future release.

I hope this helps! If the problem persists, feel free to share more details, and I'll be happy to assist further.

@mauricedoepke
Copy link
Contributor

upgrading expo constants to 14.5.0 as mentioned here: expo/expo#23457 fixed this for me.

@ftognetto
Copy link

Hello, we have the same identical issue.
The solution proposed from ChatGpt is not working on our side, because we have no :expo-constants:packageReleaseAssets task in node_modules/expo-constants/android/build.gradle...
Also upgrading 14.5.0 is not working because we are already on that version.
Has anyone else encountered this error?

@svilappsrl

@svilappsrl
Copy link

@mauricedoepke
Updating to npm i [email protected] not only doesn't fix anything but also breaks npx expo-doctor with the following message:

Some dependencies are incompatible with the installed expo version:
  [email protected] - expected version: ~14.4.2

The installed expo version is "expo": "^49.0.18"

@noomorph
With "expo-constants": "~14.4.2" installed I do not have any mention of :expo-constants:packageReleaseAssets nor :expo-constants:copyDebugExpoConfig nor even :expo-constants: in any *.gradle file across the entire project (including node_modules of course).

@signor-mike
Copy link

signor-mike commented Dec 14, 2023

My workaround:

At the end of /node_modules/expo-constants/android/build.gradle:

  // workaround for https://github.com/wix/Detox/issues/4220
  afterEvaluate {
      tasks.matching { it.name.startsWith('package') && it.name.endsWith('Assets') }.all {
          dependsOn ':expo-dev-menu:copyAssets', ':expo-constants:copyDebugExpoConfig'
          mustRunAfter ':expo-dev-menu:copyAssets', ':expo-constants:copyDebugExpoConfig', ':expo-constants:copyReleaseExpoConfig'
      }
  }

At the end of /node_modules/expo-dev-menu/android/build.gradle:

// workaround for https://github.com/wix/Detox/issues/4220
afterEvaluate {
    tasks.matching { it.name == 'packageReleaseAssets' }.all {
        dependsOn ':expo-dev-menu:copyAssets'
        mustRunAfter ':expo-dev-menu:copyAssets'
    }
}

For the workaround to survive each npm install I used https://github.com/ds300/patch-package


If encountering Java Heap error:
Add the following to package.json:

"overrides": {
    "@expo/config-plugins": "~7.2.2"
  }

create modifiedGradle.js with following content:

const { withGradleProperties } = require('@expo/config-plugins');

module.exports = (config) => {
  const newGradleProperties = [
    {
      type: 'property',
      key: 'org.gradle.jvmargs',
      value: '-Xmx6144m -XX:+HeapDumpOnOutOfMemoryError',
    },
  ];

  return withGradleProperties(config, (config) => {
    newGradleProperties.map((gradleProperty) => {
      if (config.modResults.map((item) => item.key).includes(gradleProperty.key)) {
        config.modResults.map((item) => {
          if (item.key === gradleProperty.key) {
            item.value = gradleProperty.value;
          }
        });
      } else {
        config.modResults.push(gradleProperty);
      }
    });

    return config;
  });
};

and update app.config.js:

module.exports = {
  // ... other config
  plugins: [['./modifiedGradle', 'custom']],
};

And that fixed the build for me.

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Mar 17, 2024
@batazo
Copy link

batazo commented Mar 17, 2024

It is still prolem

@stale stale bot removed the 🏚 stale label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants