Skip to content

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

Description

@ko-devHong

🐛 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:

packagecom.control;
importandroid.widget.Toast;
importcom.facebook.react.bridge.NativeModule;
importcom.facebook.react.bridge.ReactApplicationContext;
importcom.facebook.react.bridge.ReactContext;
importcom.facebook.react.bridge.ReactContextBaseJavaModule;
importcom.facebook.react.bridge.ReactMethod;
importandroid.os.Parcel;
importandroid.os.Parcelable;
importjava.util.Map;
importjava.util.HashMap;
importjava.io.Serializable;
importjava.util.ArrayList;
importjava.util.List;
publicclassInfoextendsReactContextBaseJavaModuleimplementsSerializable, Parcelable {
privatestaticfinalStringDURATION_SHORT_KEY = "SHORT";
privatestaticfinalStringDURATION_LONG_KEY = "LONG";
publicInfo(ReactApplicationContextreactContext) {
super(reactContext);
}
@OverridepublicStringgetName() {
return"Info";
}
privateStringType = "";
@ReactMethod(isBlockingSynchronousMethod = true)
publicStringgetType() {
returnType;
}
@ReactMethodpublicvoidsetType(StringType) {
this.Type = Type;
}
...
@OverridepublicvoidwriteToParcel(Parceldest, intflags) {
dest.writeString(Type);
}
publicstaticfinalCreator<Info> CREATOR = newCreator<Info>() {
publicInfocreateFromParcel(Parcelin) {
returnnewInfo(in);
}
publicInfo[] newArray(intsize) {
returnnewInfo[size];
}
};
publicInfo(Parcelin) {
super(null);
coinType = in.readString();
}
}

Manager.java:

packagecom;
importandroid.widget.Toast;
importandroid.content.Context;
importcom.facebook.react.bridge.NativeModule;
importcom.facebook.react.bridge.ReactApplicationContext;
importcom.facebook.react.bridge.ReactContext;
importcom.facebook.react.bridge.ReactContextBaseJavaModule;
importcom.facebook.react.bridge.ReactMethod;
importcom.facebook.react.bridge.ReadableMap;
importcom.control.Info;
importio.realm.Realm;
importio.realm.RealmConfiguration;
importio.realm.RealmMigration;
importjava.util.Map;
importjava.security.Security;
importjava.util.ArrayList;
importjava.util.HashMap;
importjava.util.List;
publicclassManagerextendsReactContextBaseJavaModule {
privatestaticfinalStringDURATION_SHORT_KEY = "SHORT";
privatestaticfinalStringDURATION_LONG_KEY = "LONG";
privateReactApplicationContextmReactContext;
publicManager(ReactApplicationContextreactContext) {
super(reactContext);
mReactContext = reactContext;
}
@OverridepublicStringgetName() {
return"Manager";
}
...
privateInfoinfo;
@ReactMethod(isBlockingSynchronousMethod = true)
publicInfogetInfo() {
returninfo;
}
...
}

App.js

importReact,{Component}from"react";import{StyleSheet,Text,View,NativeModules}from"react-native";const{ Manager, Info }=NativeModules;exportdefaultclassAppextendsReact.Component{constructor(props){super(props);this.state={};}componentWillMount(){manager=newManager();manager.getInfo();}render(){return(<Viewstyle={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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions