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

Question: Error:Java exception in 'NativeModules' java.lang.RuntimeException: Got unknown argument class: Info #24285

Closed
ko-devHong opened this issue Apr 3, 2019 · 1 comment
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@ko-devHong
Copy link

I'm currently creating a 'react-native module'.

I'm referring to this.

I'm trying to create and apply a module, but there's a problem with the function.

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>
    );
  }
}

As you can see, I'm going to use the argument type of the function as Info.

However, 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 ...

How can I use 'Info' as an argument type? Please help me a lot.

@ko-devHong ko-devHong added the Type: Question Issues that are actually questions and not bug reports. label Apr 3, 2019
@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

👉 Click here if you want to report a reproducible bug or regression in React Native.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: No Template labels Apr 3, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Apr 3, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

2 participants