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

无法将类 JMessageReactPackage中的构造器 JMessageReactPackage应用到给定类型; #188

Open
haihaifgdfsgf opened this issue Sep 8, 2019 · 9 comments

Comments

@haihaifgdfsgf
Copy link

"jcore-react-native": "^1.3.5",
"jmessage-react-plugin": "^3.1.7",

react-native-cli: 2.0.1
react-native: 0.60.5

``
1
2

@yangkezun
Copy link

我也是这个问题,楼主解决了吗

@yylingsj
Copy link

老兄,没仔细看文档的结果,我第一次也出这个错了,应该都是直接执行react-native link才出错的,执行之后,还要修改一个地方。
在 MainApplication 中加上 JMessagePackage 即可,JMessagePackage 有一个参数,设置是否弹出 toast。

// 如果设置为 true,则不弹出 toast。
private boolean shutdownToast = false;

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new JMessageReactPackage(shutdownToast),
    );
}

@yylingsj
Copy link

后续可能还会遇到错误,我的就是,因为readme文档说明不全,缺少对jcore-react-native的说明,link也不会自动加上...
错误描述:调用setDebugModel方法会出现'Could not invoke JMessageModule.setDebugMode...''

产生这个错误的原因是jmessage官方readme文档缺陷造成的,文档中只给出了jmessage的配置,而没给出jcore的配置,希望官方把文档fix一下:

fix 1:/android/setting.gradle中添加

include ':jcore-react-native'
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')

fix 2:/android/app/build.gradle中添加

compile project(':jcore-react-native')

@b1ngx
Copy link

b1ngx commented Dec 29, 2019

React Native 在 0.60 版本后加入 Autolinking 功能,禁用 autolink,手动 link

执行 npm run react-native link jmessage-react-plugin

在项目根目录添加 react-native.config.js 文件,增加如下内容

module.exports = {
  dependencies: {
    'jmessage-react-plugin': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

MainApplication.java 中加上 new JMessageReactPackage(shutdownToast)

private boolean shutdownToast = false;

@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  // Packages that cannot be autolinked yet can be added manually here, for example:
  // packages.add(new MyReactNativePackage());
  packages.add(new JMessageReactPackage(shutdownToast));
  return packages;
}

@Macrow
Copy link

Macrow commented Jan 21, 2020

不用这样麻烦,直接在项目根目录下,添加 react-native.config.js 文件

module.exports = {
  dependencies: {
    'jmessage-react-plugin': {
      platforms: {
        android: {
          packageInstance: 'new JMessageReactPackage(false)'
        }
      }
    },
  }
};

这里的初始化参数,根据自己的情况来修改即可。

@yylingsj
Copy link

不用这样麻烦,直接在项目根目录下,添加 react-native.config.js 文件

module.exports = {
  dependencies: {
    'jmessage-react-plugin': {
      platforms: {
        android: {
          packageInstance: 'new JMessageReactPackage(false)'
        }
      }
    },
  }
};

这里的初始化参数,根据自己的情况来修改即可。

正解

@Liqiankun
Copy link

@Macrow 正解。

@Liqiankun
Copy link

Liqiankun commented Sep 28, 2020

@yylingsj 我现在确实出现了这个问题
java.lang.RuntimeException: Could not invoke JMessageModule.setDebugMode但是按照你上边那个回答没能解决。请问应该怎么办?
极光社区问题描述

@Liqiankun
Copy link

@haihaifgdfsgf 请问你遇到了Could not invoke JMessageModule.setDebugMode的问题吗?

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

6 participants