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

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

Closed
jvgeee opened this issue Mar 28, 2023 · 33 comments

Comments

@jvgeee
Copy link

jvgeee commented Mar 28, 2023

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

@anhquan291
Copy link

I'm facing the same issue !

@purevsurena
Copy link

This error occurred on the react-native v0.70.4. Problem was here this line. apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

@bmaluff
Copy link
Contributor

bmaluff commented Mar 28, 2023

This error occurred on the react-native v0.70.4. Problem was here this line. apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

What do you mean @purevsurena? You missed the line? or changed something inside the file?

@bmaluff
Copy link
Contributor

bmaluff commented Mar 28, 2023

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

The line 5 in codepush.gradle should return a map, and is returning an ArrayList which doesn't support get() method

I just pushed a PR with the solution to this issue #2471

@malikzype
Copy link

Facing same issue

@vlack-coder
Copy link

vlack-coder commented Mar 31, 2023

I used v8 on a newly created project and it worked fine for both iOS and Android.

But for my old project. it only worked for iOS and gave this error for Android.

As @jvgeee said, I downgraded to v7 and it worked fine

@malikzype downgrade to v7 for a quick fix

@Omaressam9500
Copy link

I am facing same error

@malikzype
Copy link

@vlack-coder Yes downgrading to v7 works fine

@JB-CHAUVIN
Copy link

Same problem goes for me.
I tried the patch mentionned above but I have an other error now :

FAILURE: Build failed with an exception.

* Where:
Script '/Users/cegedim/Documents/Cegedim/Code/Mobile/keynote2/packages/mobile-pro/node_modules/react-native-code-push/android/codepush.gradle' line: 6

* What went wrong:
A problem occurred evaluating script.
> Cannot invoke method get() on null object

* 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.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 4s

@blueberry6401
Copy link

v8 only works with react-native 0.71. Nothing is mentioned in the docs.

@NguyenQuocAnDev27
Copy link

i work on react native version 0.66, codepush version 8.0.0 and got this issue too.

@RoyalBosS-Ayush
Copy link

Any update? Facing same on rn 0.68.0

@shahanshah-cutshort
Copy link

Downgrading to 7..0.0 with RN 0.70.5 is working.

@nassimmiled
Copy link

nassimmiled commented Apr 11, 2023

same here for React Native 0.64.2

@NguyenQuocAnDev27
Copy link

NguyenQuocAnDev27 commented Apr 12, 2023

Hello. I have solved this issue by doing the following:
image
In this step, find the first line then insert the second line. The first line is already there. I copied and pasted 2 line at the end build.gradle file so first line is already there so it make file have 2 line have the same code so it cause error.
image
In this step, delete include ':app' then copy paste this code to there.
image
This step insert library then find ReactNativeHost then insert this code:

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

image
In this step, DeploymentKey can be get on web appcenter or use command appcenter codepush deployment list -a / -k

so i have ownerName like nguyenquocan and app name like testApp
i will have this command:
appcenter codepush deployment list -a nguyenquuocan/testApp -k
if you have @gmail.com at the end owner name
-> appcenter codepush deployment list -a nguyenquocan-gmail.com/testApp -k

And you want to make update change you must change versionCode in android/app/build.gradle build.gradle will have this object -> android{defaultConfig{versionCode}} change like 1 -> 2. And change versionName don't make update in your app. It is the target you will update. if you have version 1.0.0 and version 1.0.1, it will not update version 1.0.0 to 1.0.1

if you want more details. You can read in this docs.
https://learn.microsoft.com/en-us/appcenter/distribution/codepush/rn-get-started#android-setup

And 1 more thing. Version codepush support differnt sdk. So i have sdk version 30 codepush version 8.0.0 seem not support this. So i use version 7.0.4 then it work. Detail of my sdk i use:
image

That's all.
I hope this will be useful.

@RyanPliske
Copy link

same with RN 0.70.5

@taongocsontam
Copy link

taongocsontam commented Apr 24, 2023

I'm find resolve here: #2471
dbbc0df

@prashantsoni-ai
Copy link

For anyone who is still facing the issue. follow these steps with library "react-native-code-push": "^7.0.1" , "react-native": "0.70.5"
Codepush - appcenter - OTA - Autoupdate
Install library - react-native-code-push

Install appcenter CLI - npm install -g appcenter-cli

Login to app center - appcenter login

Create a new app - appcenter apps create -d <AppName> -o <OS> -p React-Native

PS: Replace app name and os to your requirements.

Create Production and Staging keys using -

appcenter codepush deployment add -a <ownerName>/<appName> Production

appcenter codepush deployment add -a <ownerName>/<appName> Staging

PS: Replace ownerName and appName to your ownerName and appName

Once the app is set up, verify it with the appcenter.

Changes in React Native codebase.
//Add this code to MainApplication.java

import com.microsoft.codepush.react.CodePush;  //import this library
@Override //Add this code to the ReactNativeHost function. 
protected String getJSBundleFile() {
	return CodePush.getJSBundleFile();
}

<string moduleConfig="true" name="CodePushDeploymentKey">ProductionKey</string>
PS: Replace the production key to you production/staging keys obtained in step 5

apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

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

PS: Dont enter the above code in the If block.

PS: this code creates a codepush wrapper class and we wrap the App component in this class

import codePush from "react-native-code-push"; 
const codePushOptions = { 
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, 
installMode: codePush.InstallMode.IMMEDIATE,
};


export default App = codePush(codePushOptions)(App);

Once all of the above steps are completed, run the following command to create the deployment.
appcenter codepush deployment create -a <app_name> -d <deployment_name>

And run the following command to update your deployment.

appcenter codepush release-react -a <app_name> -d <deployment_name>

PS: Replace the app_name and deployment_name to your app’s name and Staging/Production respectively.

Note: Codepush might have some issues with some versions of ReactNative So make sure you have “react-native-code-push” → “7.0.1” if using “react-native" → “^0.70.0”
References → Auto Update``

@Azhar456
Copy link

i solved this solved issue

"react-native": "0.68.2",
"react-native-code-push": "8.0.1",

I didn't import the import com.microsoft.codepush.react.CodePush;
in MainApplication.java

Note! You might have the following error.

Cannot add task 'bundleDebugJsAndAssets' as a task with that name already exists.
Please double-check whether you have a duplicate code in root/android/app/build.gradle .

@savaskalkan
Copy link

I solved this guys.
I just downgrade codepush version from 8.0.1 to 7.0.4
There is an issue that needs to be fixed by codepush team

@harish92
Copy link

+1 I'm also facing same issue.

@Azhar456
Copy link

+1 I'm also facing same issue.

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

@harish92
Copy link

yes followed all the steps still facing same issue.

@Azhar456
Copy link

Azhar456 commented May 18, 2023

yes followed all the steps still facing same issue.

show your code or if you want help then will connect

@FrontendTerminator
Copy link

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

@jvgeee
Copy link
Author

jvgeee commented May 22, 2023

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 jvgeee closed this as completed May 22, 2023
@Gamote
Copy link

Gamote commented May 30, 2023

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

@locht
Copy link

locht commented Jun 2, 2023

downgrade v7.0.4 working for me

@MateusAndrade
Copy link

Same issue with:

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

@jesus-castro3
Copy link

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.

@kigh143
Copy link

kigh143 commented Oct 18, 2023

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

@ranavikrantsingh07
Copy link

ranavikrantsingh07 commented Feb 22, 2024

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.
==============================================================================`

@vanqui123
Copy link

vanqui123 commented May 22, 2024

use patch package and change file codepush.gradle

react-native-code-push+8.2.2.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests