react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

No signature of method: java.util.ArrayList.get() is applicable for argument types: () values: []

Open jvgeee opened this issue 3 years ago • 33 comments

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Getting this error when running Android build (in Android Studio) on the latest version of RN Codepush (8.0.0)

Script './node_modules/react-native-code-push/android/codepush.gradle' line: 6

* What went wrong:
A problem occurred evaluating script.
> No signature of method: java.util.ArrayList.get() is applicable for argument types: () values: []
  Possible solutions: get(int), get(int), set(int, java.lang.Object), set(int, java.lang.Object), grep(), grep()

Works fine on V7, assume that either the docs need to be upgraded for v8 or there's a bug somewhere

jvgeee avatar Mar 28 '23 04:03 jvgeee

+1 I'm also facing same issue.

harish92 avatar May 18 '23 07:05 harish92

+1 I'm also facing same issue.

please recheck the if you follow all the steps correctly or not

Azhar456 avatar May 18 '23 07:05 Azhar456

yes followed all the steps still facing same issue.

harish92 avatar May 18 '23 08:05 harish92

yes followed all the steps still facing same issue.

show your code or if you want help then will connect

Azhar456 avatar May 18 '23 08:05 Azhar456

Just got the same error. But I solved it by downgrading from 8.0.1 to 7.0.1 code push version. My react native version 0.64.4

FrontendTerminator avatar May 18 '23 11:05 FrontendTerminator

Upgraded React Native to 0.71.4 and V8 of rn-code-push no longer causes this error in Android.

If you're on an earlier version of React Native, the solution is to use v7 of this plugin, e.g. yarn add react-native-code-push@7.

jvgeee avatar May 22 '23 06:05 jvgeee

If you want to make it work with a 0.6x React Native use this patch.

We use the following versions: react-native: 0.64.4 react-native-code-push: 8.0.1

If you use patch-package this is the patch:

react-native-code-push+8.0.1.patch
diff --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

Gamote avatar May 30 '23 14:05 Gamote

downgrade v7.0.4 working for me

locht avatar Jun 02 '23 08:06 locht

Same issue with:

        "react-native": "^0.72.0",
        "react-native-code-push": "^8.0.2",

MateusAndrade avatar Jun 26 '23 14:06 MateusAndrade

For anyone reading this, fyi react-native-code-push v8.0.0+ is incompatible with versions 0.65-0.70+ , took me a while to figure that out. Either you upgrade to RN 71 to use codepush v8 or you still with v7 for now.

jesus-castro3 avatar Jul 06 '23 22:07 jesus-castro3

Downgrading helped me but then faced this error : The CodePush module doesn't appear to be properly installed.

kigh143 avatar Oct 18 '23 15:10 kigh143

Iam Still facing the same issue downgraded the Codepush version to 7 still the same currently Iam using [email protected] `FAILURE: Build completed with 2 failures. So without codepush it works fine once I installed this I faced this issue

1: Task failed with an exception.

  • Where:
  • What went wrong: A problem occurred evaluating script.

No signature of method: java.util.ArrayList.get() is applicable for argument types: () values: [] Possible solutions: get(int), get(int), set(int, java.lang.Object), set(int, java.lang.Object), grep(), grep()

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================

2: Task failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

compileSdkVersion is not specified. Please add it to build.gradle

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================`

ranavikrantsingh07 avatar Feb 22 '24 07:02 ranavikrantsingh07

use patch package and change file codepush.gradle

react-native-code-push+8.2.2.patch

vanqui123 avatar May 22 '24 06:05 vanqui123