React-native-code-push: Cannot build on RN 0.62

Created on 27 Mar 2020  路  25Comments  路  Source: microsoft/react-native-code-push

Hello,
when I try to build an app based on RN 0.62 and using latest version of CodePush I get this error:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :react-native-code-push.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-code-push:
          - None of the consumable configurations have attributes.

How can this be fixed?

Thank you,
Marco

compatibility fix-in-master

Most helpful comment

Quick update.

By applying:
include ':app', ':react-native-code-push' project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

below:

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

in settings.gradle (I was placing it above that line) it seems to work, I have had also to change this line: CodePush.java and replace isReloadOnJSChangeEnabled to isHotModuleReplacementEnabled as suggested here #1823

since I have read that with Rn 0.62 Fast Refresh has been enabled by default and replaced hot reload.

This is clearly a workaround and we are waiting for the official fix.

Hope this helps.

All 25 comments

same issue

Same issue also here

Hi @marf ,
Thank you for reporting!

Try to add the following additions to your android/settings.gradle file:

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

We are investigating this issue now, let me know if this helped you.

Hi @marf ,
Thank you for reporting!

Try to add the following additions to your android/settings.gradle file:

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

We are investigating this issue now, let me know if this helped you.

Hello @andreidubov,
I have tried adding that line but now I got this error:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :react-native-code-push.

Thank you

Same issue :(

Hi @marf ,
Thank you for reporting!

Try to add the following additions to your android/settings.gradle file:

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
We are investigating this issue now, let me know if this helped you.

@andreidubov even after applying your solution, i am getting the same error found in issue #1823 .

Any update on when this will be resolved?

Quick update.

By applying:
include ':app', ':react-native-code-push' project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

below:

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

in settings.gradle (I was placing it above that line) it seems to work, I have had also to change this line: CodePush.java and replace isReloadOnJSChangeEnabled to isHotModuleReplacementEnabled as suggested here #1823

since I have read that with Rn 0.62 Fast Refresh has been enabled by default and replaced hot reload.

This is clearly a workaround and we are waiting for the official fix.

Hope this helps.

@marf Thanks for the update. I'm about to try and will give feedback on whether or not it works for me. I'm in the middle of bootstrapping a clean version of RN 0.62

My project uses RN 0.62.0

@marf for me, following the instructions for RN >= 0.60 for Android I get these errors:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :react-native-code-push.
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :react-native-code-push.
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :react-native-code-push.
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :react-native-code-push.
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :react-native-code-push.

Here were my steps afterwards:

  1. Added the last two lines of the following to settings.gradle for my main project.
rootProject.name = 'HailTrace'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

After trying to build, I received this error:

error: cannot find symbol
                isLiveReloadEnabled = devInternalSettings.isReloadOnJSChangeEnabled();
  1. I then followed @marf advice and changed CodePush.java by doing the following:
    Line 157
isLiveReloadEnabled = devInternalSettings.isHotModuleReplacementEnabled();

It used to be:

isLiveReloadEnabled = devInternalSettings.isReloadOnJSChangeEnabled();
  1. My project built! I'm assuming that it will work as expected, but need to do more testing. Obviously there is some kind of configuration error related to the latest version of RN (0.62). This needs to be addressed asap since the temporary fix is not ideal. @andreidubov I hope this helps.

The solution posted by @AustinHunt above worked for me.

To patch this for now, I added this to my yarn's postinstall so it doesn't break other users' code on my team:

sed -i -e "s/isReloadOnJSChangeEnabled/isHotModuleReplacementEnabled/g" "node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java"

To patch this for now, I added this to my yarn's postinstall so it doesn't break other users' code on my team:

sed -i -e "s/isReloadOnJSChangeEnabled/isHotModuleReplacementEnabled/g" "node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java"

This is a nice solution. I've found it semi-frustrating every time I install a new yarn module to need to replicate step 3.

@lukebars is there anything we need to change besides updating the code push version? I'm still getting the error even after #1829 upgrade

> Could not resolve all task dependencies for configuration ':app:debugAndroidTestCompileClasspath'.
   > Could not resolve project :react-native-code-push.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-code-push:
          - None of the consumable configurations have attributes.

Hi all,
Thanks for reporting!

As @lukebars mentioned, https://github.com/microsoft/react-native-code-push/pull/1829 solved this issue and we made new release: https://github.com/microsoft/react-native-code-push/releases/tag/v6.2.0

@bgold0, Please check the updated docs setup section: https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-installation-and-configuration-for-react-native-060-version-and-above-android
You have to add project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') to your android/settings.gradle file.

I'm going to close this issue for now. Please feel free to reopen it if you have any questions.

@alexandergoncharov This has always been in my android/settings.gradle file

project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app'

@alexandergoncharov This has always been in my android/settings.gradle file

project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app'

Have you updated your build.gradle?

I did with 4 steps as the docs guide, but it doesn't work with rn0.62

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :react-native-code-push.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-code-push:
          - None of the consumable configurations have attributes.

Doest work for me either

That worked for me too .. I had to change from this

...

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':app'

to (notice I've moved the code-push line BELOW the apply line and merged it with the already existing include ':app' which was there). I initially just included the line above together with the rest of the includes I have .. and kept the include ':app' separate as the last line - but that won't work.

...

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

Hi all,
Thanks for reporting!

As @lukebars mentioned, #1829 solved this issue and we made new release: https://github.com/microsoft/react-native-code-push/releases/tag/v6.2.0

@bgold0, Please check the updated docs setup section: https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-installation-and-configuration-for-react-native-060-version-and-above-android
You have to add project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') to your android/settings.gradle file.

I'm going to close this issue for now. Please feel free to reopen it if you have any questions.

@alexandergoncharov, not sure what you mean by "solved this" when, on RN 0.62 and RNCodePush 0.62, we have to manually add the changes suggested in this and the related issue? I would assume solving the issue would mean having autolinking working?

@madandrija if you want autolinking you just need this in your react-native.config.js

module.exports = {
  dependencies: {
    'react-native-code-push': {
      platforms: {
        android: {
          sourceDir: '../node_modules/react-native-code-push/android/app',
        },
      },
    },
  },
};

But I agree that this should be fixed on a package level, and we shouldn't have to do this manual work

Hello

By adding ths:
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

after this line:
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

in your settings.gradle file and add this line at top:

import com.microsoft.codepush.react.CodePush;

and this in ReactNativeHost function:

@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}

in your MainApplication.java file and dont forget to add this:

<string name="CodePushDeploymentKey">deploymentKey</string>

in your android/app/src/main/res/values/strings.xml file, it worked for me.

hopefully, it will work for u as well

thanks

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

put these line at bottom of settings.gradle..it worked for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fanzhiri picture fanzhiri  路  3Comments

kevando picture kevando  路  4Comments

SudoPlz picture SudoPlz  路  4Comments

Phredward picture Phredward  路  3Comments

djw27 picture djw27  路  3Comments