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

I'm facing the same issue !

anhquan291 avatar Mar 28 '23 14:03 anhquan291

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"

purevsurena avatar Mar 28 '23 14:03 purevsurena

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 avatar Mar 28 '23 17:03 bmaluff

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

bmaluff avatar Mar 28 '23 17:03 bmaluff

Facing same issue

malikzype avatar Mar 31 '23 05:03 malikzype

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

vlack-coder avatar Mar 31 '23 15:03 vlack-coder

I am facing same error

Omaressam9500 avatar Apr 02 '23 20:04 Omaressam9500

@vlack-coder Yes downgrading to v7 works fine

malikzype avatar Apr 03 '23 06:04 malikzype

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

JB-CHAUVIN avatar Apr 03 '23 07:04 JB-CHAUVIN

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

blueberry6401 avatar Apr 03 '23 09:04 blueberry6401

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

DevMobileAn27 avatar Apr 07 '23 04:04 DevMobileAn27

Any update? Facing same on rn 0.68.0

RoyalBosS-Ayush avatar Apr 10 '23 07:04 RoyalBosS-Ayush

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

shahanshah-cutshort avatar Apr 11 '23 06:04 shahanshah-cutshort

same here for React Native 0.64.2

nassimmiled avatar Apr 11 '23 13:04 nassimmiled

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.

DevMobileAn27 avatar Apr 12 '23 04:04 DevMobileAn27

same with RN 0.70.5

RyanPliske avatar Apr 20 '23 19:04 RyanPliske

I'm find resolve here: #2471 https://github.com/microsoft/react-native-code-push/pull/2471/commits/dbbc0df43351ebee9eff7a7ae05bb3443a65304d

taongocsontam avatar Apr 24 '23 07:04 taongocsontam

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

prashantmaya avatar May 09 '23 06:05 prashantmaya

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 .

Azhar456 avatar May 17 '23 06:05 Azhar456

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

savaskalkan avatar May 17 '23 19:05 savaskalkan