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

error: reference to reject is ambiguous #30

Closed
compski opened this issue Apr 10, 2019 · 9 comments
Closed

error: reference to reject is ambiguous #30

compski opened this issue Apr 10, 2019 · 9 comments

Comments

@compski
Copy link

compski commented Apr 10, 2019

BUILD FAILED in 5s
15 actionable tasks: 12 executed, 3 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

C:\Users\username\Documents\JS projects\pingtest>react-native run-android
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Task :react-native-ping:compileDebugJavaWithJavac
C:\Users\username\Documents\JS projects\pingtest\node_modules\react-native-ping\android\src\main\java\com\reactlibrary\RNReactNativePingModule.java:28: error: reference to reject is ambiguous
promise.reject(error.getCode(), error.getMessage(), null);
^
both method reject(String,String,Throwable) in Promise and method reject(String,String,WritableMap) in Promise match
C:\Users\username\Documents\JS projects\pingtest\node_modules\react-native-ping\android\src\main\java\com\reactlibrary\RNReactNativePingModule.java:54: error: reference to reject is ambiguous
promise.reject(error.getCode(), error.getMessage(), null);
^
both method reject(String,String,Throwable) in Promise and method reject(String,String,WritableMap) in Promise match
C:\Users\username\Documents\JS projects\pingtest\node_modules\react-native-ping\android\src\main\java\com\reactlibrary\RNReactNativePingModule.java:67: error: reference to reject is ambiguous
promise.reject(error.getCode(), error.getMessage(), null);
^
both method reject(String,String,Throwable) in Promise and method reject(String,String,WritableMap) in Promise match
3 errors

Task :react-native-ping:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-ping:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • 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

BUILD FAILED in 7s
15 actionable tasks: 1 executed, 14 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

@maxhis
Copy link

maxhis commented Apr 11, 2019

Same here.

Changing all promise.reject(error.getCode(), error.getMessage(), null); to promise.reject(error.getCode(), error.getMessage()); in RNReactNativePingModule.java can fix the compile error.

However, got a new error:

Attempt to invoke interface method 'boolean com.facebook.react.bridge.ReadableMap.hasKey(java.lang.String)' on a null object reference
start
    RNReactNativePingModule.java:34

My workaround is replacing the line 34 if (option.hasKey(TIMEOUT_KEY)) { with if (option != null && option.hasKey(TIMEOUT_KEY)) {

@RoJoHub
Copy link
Owner

RoJoHub commented Apr 12, 2019

@compski @maxhis
Hi guys😀
I will fix this problem in 1.2.2.

The reason for this problem is that the 0.58 version of react native has changed. But it is now compatible.

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md

[0.58] => Added => Android specific

  • Native Modules can now reject a promise with an additional WritableMap arg for extra properties (userInfo). See the interface defined in Promise.java for available methods. This is accessible in JavaScript as Error.userInfo. This is to match iOS's existing Error.userInfo behaviour. See PR for examples. (#20940 by @Salakar)

@RoJoHub RoJoHub closed this as completed Apr 16, 2019
@bogdandobritoiu
Copy link

Still not fixed, checked 1.2.2. I can confirm what @maxhis did works

@RoJoHub
Copy link
Owner

RoJoHub commented Jun 3, 2019

Still not fixed, checked 1.2.2. I can confirm what @maxhis did works

Please run example for test.
It seem to ok in example

@bogdandobritoiu
Copy link

Line 34 is still the same. Tried it on my local machine and it works as suggested by @maxhis .

if (option.hasKey(TIMEOUT_KEY)) {
with
if (option != null && option.hasKey(TIMEOUT_KEY)) {

@RoJoHub
Copy link
Owner

RoJoHub commented Jun 4, 2019

Line 34 is still the same. Tried it on my local machine and it works as suggested by @maxhis .

if (option.hasKey(TIMEOUT_KEY)) {
with
if (option != null && option.hasKey(TIMEOUT_KEY)) {

Could you please tell which version version you use?
React Native And react-native-ping

@bogdandobritoiu
Copy link

"react-native-ping": "^1.2.2",
"react-native": "^0.59.8",

@RoJoHub
Copy link
Owner

RoJoHub commented Jun 10, 2019

Please watch package-lock.json or yarn.lock.
Check if the version of react-native-ping

image

image

@bogdandobritoiu
Copy link

Ah yes, my lock.json had the wrong version. Sorry for the misunderstanding! Thank you for quick responses

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

4 participants