-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update codepush.gradle #2471
Update codepush.gradle #2471
Conversation
config was receiving an ArrayList as a false case, but ArrayLists don't support get() method, so it should receive a Map instance.
Hi @bmaluff, Throwing the below error. PFA |
Same error as @sureshbakshi
|
Add more verifications for config variable
Thanks for the reviews!! Updated the code to fix it according to your findings!!! |
@sureshbakshi Can you test again, plz? |
Hello, right now I patched changes from this pr and it helped to fix the problem. I hope it will be in release soon |
I can confirm that this fixed our issue as well. We use the following versions: If you use react-native-code-push+8.0.1.patchdiff --git a/node_modules/react-native-code-push/android/codepush.gradle b/node_modules/react-native-code-push/android/codepush.gradle
index a0f9d27..09a0951 100644
--- a/node_modules/react-native-code-push/android/codepush.gradle
+++ b/node_modules/react-native-code-push/android/codepush.gradle
@@ -1,9 +1,15 @@
// Adapted from https://raw.githubusercontent.com/facebook/react-native/d16ff3bd8b92fa84a9007bf5ebedd8153e4c089d/react.gradle
+/**
+ * A patch was applied to this file to fix an issue with the CodePush plugin
+ * Issue: https://github.com/microsoft/react-native-code-push/issues/2470#issuecomment-1519511406
+ * Patch: https://github.com/microsoft/react-native-code-push/pull/2471
+ */
+
import java.nio.file.Paths;
-def config = project.extensions.findByName("react") ?: []
-def bundleAssetName = config.bundleAssetName.get() ?: "index.android.bundle"
+def config = project.extensions.findByName("react") ?: [:]
+def bundleAssetName = config.bundleAssetName ? config.bundleAssetName.get() : "index.android.bundle"
// because elvis operator
def elvisFile(thing) {
@@ -24,7 +30,7 @@ android.buildTypes.each { buildType ->
}
gradle.projectsEvaluated {
- def debuggableVariants = config.debuggableVariants.get() ?: ['debug']
+ def debuggableVariants = config.debuggableVariants ? config.debuggableVariants.get() : ['debug']
android.applicationVariants.all { variant ->
// No code push for debuggable variants
@@ -49,8 +55,8 @@ gradle.projectsEvaluated {
def jsBundleFile;
// Additional node commandline arguments
- def nodeExecutableAndArgs = config.nodeExecutableAndArgs.get() ?: ["node"]
- def extraPackagerArgs = config.extraPackagerArgs.get() ?: []
+ def nodeExecutableAndArgs = config.nodeExecutableAndArgs ? config.nodeExecutableAndArgs.get(): ["node"]
+ def extraPackagerArgs = config.extraPackagerArgs ? config.extraPackagerArgs.get() : []
// Make this task run right after the bundle task
def generateBundledResourcesHash;
@@ -73,11 +79,11 @@ gradle.projectsEvaluated {
runBefore("merge${targetName}Assets", generateBundledResourcesHash)
} else {
def jsBundleDirConfigName = "jsBundleDir${targetName}"
- jsBundleDir = elvisFile(config."$jsBundleDirConfigName").get() ?:
+ jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ? elvisFile(config."$jsBundleDirConfigName").get():
file("$buildDir/intermediates/assets/${targetPath}")
def resourcesDirConfigName = "resourcesDir${targetName}"
- resourcesDir = elvisFile(config."${resourcesDirConfigName}").get() ?:
+ resourcesDir = elvisFile(config."${resourcesDirConfigName}") ? elvisFile(config."${resourcesDirConfigName}").get():
file("$buildDir/intermediates/res/merged/${targetPath}")
// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0 |
Using this patch fixed the build error for rn 0.72 🚀 |
@DmitriyKirakosyan Can you review this PR so the fix can be available for everyone, plz?? |
@MateusAndrade Please provide steps how to use this patch package |
Checkout Then create a file out of the code block, call it |
@bmaluff Can you please post steps on how to reproduce the issue? |
Anyone knows why the react extension is not found in extensions and why does config file fallback to empty array?
I get that this PR fixes wrongly accessed type, but why does it even comes to that? EDIT: Reverting to v7 fixed the issue |
config was receiving an ArrayList as a false case, but ArrayLists don't support get() method, so it should receive a Map instance.