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:Java exception in 'NativeModules' java.lang.RuntimeException: Got unknown argument class: Info #24287

Closed
ko-devHong opened this issue Apr 3, 2019 · 3 comments
Labels
Bug Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ko-devHong
Copy link

ko-devHong commented Apr 3, 2019

🐛 Bug Report

as you can see below 'error code', the error occur.

    Java exception in 'NativeModules'
    
    java.lang.RuntimeException: Got unknown argument class: Info
    com.facebook.react.bridge.JavaMethodWrapper.buildArgumentExtractors ...

To Reproduce

In the 'Manager.java' file, you can 'import' the 'Info.java' file and try it as a return type.

Expected Behavior

I'd like to use the class 'Info' as a type.

Code Example

Info.java:

package com.control;

import android.widget.Toast;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Info extends ReactContextBaseJavaModule implements Serializable, Parcelable {
private static final String DURATION_SHORT_KEY = "SHORT";
    private static final String DURATION_LONG_KEY = "LONG";

public Info(ReactApplicationContext reactContext) {
        super(reactContext);
    }
@Override
    public String getName() {
        return "Info";
    }

private String Type = "";

@ReactMethod(isBlockingSynchronousMethod = true)
    public String getType() {
        return Type;
    }

    @ReactMethod
    public void setType(String Type) {
        this.Type = Type;
    }
...
@Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(Type);
    }

public static final Creator<Info> CREATOR = new Creator<Info>() {
        public Info createFromParcel(Parcel in) {
            return new Info(in);
        }

        public Info[] newArray(int size) {
            return new Info[size];
        }
    };

public Info(Parcel in) {
        super(null);
        coinType = in.readString();
    }
}

Manager.java:

package com;

import android.widget.Toast;
import android.content.Context;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;

import com.control.Info;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmMigration;

import java.util.Map;
import java.security.Security;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Manager extends ReactContextBaseJavaModule {
private static final String DURATION_SHORT_KEY = "SHORT";
    private static final String DURATION_LONG_KEY = "LONG";

private ReactApplicationContext mReactContext;

public Manager(ReactApplicationContext reactContext) {
        super(reactContext);
        mReactContext = reactContext;
    }
@Override
    public String getName() {
        return "Manager";
    }
...
private Info info;

@ReactMethod(isBlockingSynchronousMethod = true)
public Info getInfo() {
        return info;
    }
...
}

App.js

import React, { Component } from "react";
import { StyleSheet, Text, View, NativeModules } from "react-native";

const { Manager, Info } = NativeModules;

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentWillMount() {
    manager = new Manager();
    manager.getInfo();
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Test</Text>
      </View>
    );
  }
}

Environment

React Native Environment Info:
System:
OS: MacBook Pro (Retina, 13-inch, Late 2012)
CPU: 2.5 GHz Intel Core i5
Memory: 8GB 1600 MHz DDR3
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Android SDK:
API Levels: 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.2, 28.0.3
IDEs:
Android Studio: 3.3.2
npmPackages:
react: "16.5.0",
react-native: "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz"

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write `[skip envinfo]` alongside an explanation in your Environment: section.

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants