Closed juniorschroder closed 5 years ago
Plz make sure linked:
react-native link react-native-sunmi-inner-printer
Then plz check the related files to make user plugin is installed successfully. They may be settings.gradle, app/build.gradle and MainPackage.java
Further more, you may need to check the spells of the example commands and plugin names,plugin paths. I got typo issue sometimes, sorry about that.
Thnx for quick response.
Seems like don't have any typo issue.
A have Linked with success after instal npm package, check files settings.gradle, app/build.gradle it's ok, MainPackage.java doesn't exists, maybe MainApplication.java? in MainApplication.java it's OK too: package com.newerppdvmobile;
import android.app.Application;
import com.facebook.react.ReactApplication; import com.sunmi.innerprinter.SunmiInnerPrinterPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader;
import java.util.Arrays; import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SunmiInnerPrinterPackage(),
new VectorIconsPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
@Override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false); } }
here is my App.js:
/**
import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View } from 'react-native'; import { Button, Header } from 'react-native-elements'; import SunmiInnerPrinter from 'react-native-sunmi-inner-printer';
const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', });
export default class App extends Component {
teste() { console.log('obj', SunmiInnerPrinter); SunmiInnerPrinter.printString('test'); }
render() { return (
);
} }
const styles = StyleSheet.create({ welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
Should have a reference to the module class, manpackage class missing should be a problem. May you try to install a other plugin to test whether your project is fine? Emmm, what RN version you are working with?
发自我的 iPhone
在 2018年9月11日,下午11:00,José Carlos Schröder Júnior notifications@github.com 写道:
Thnx for quick response.
Seems like don't have any typo issue.
A have Linked with success after instal npm package, check files settings.gradle, app/build.gradle it's ok, MainPackage.java doesn't exists, maybe MainApplication.java? in MainApplication.java it's OK too: package com.newerppdvmobile;
import android.app.Application;
import com.facebook.react.ReactApplication; import com.sunmi.innerprinter.SunmiInnerPrinterPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader;
import java.util.Arrays; import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }
@Override protected List
getPackages() { return Arrays. asList( new MainReactPackage(), new SunmiInnerPrinterPackage(), new VectorIconsPackage() ); } @Override protected String getJSMainModuleName() { return "index"; } };
@override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
@override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false); } }
here is my App.js:
/**
Sample React Native App https://github.com/facebook/react-native @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View } from 'react-native'; import { Button, Header } from 'react-native-elements'; import SunmiInnerPrinter from 'react-native-sunmi-inner-printer';
const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', });
export default class App extends Component {
teste() { console.log('obj', SunmiInnerPrinter); SunmiInnerPrinter.printString('test'); }
render() { return (
<Header leftComponent={{ icon: 'menu', color: '#fff' }} centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }} rightComponent={{ icon: 'home', color: '#fff' }} />
Welcome to React Native!
To get started, edit App.js
{instructions}
<Button raised icon={{ name: 'cached' }} title='Print!!!' onPress={()=>{this.teste() }} />
); } }
const styles = StyleSheet.create({ welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
I'm using ReactNative Elements. this uses react-native-vector-icons (npm i --save react-native-vector-icons && react-native link react-native-vector-icons) and works fine.
I'm current using "react-native": "0.55.4",
hmmmm. one more try, uninstall and remove current react-native-sunmi-inner-printer your installed, then install the master branch via https://github.com/januslo/react-native-sunmi-inner-printer.git and test again. I have no update the NPM repo for a century. sorry about that.
Not working, same problem undefined is not an object (evaluating '_reactNativeSunmiInnerPrinter2.default.printString')
I also tried usin U sample (https://github.com/januslo/react-native-sunmi-inner-printer/blob/master/examples/index.android.js) and same error.
That is abnormal, This error usually shows the link issue. You may need to make sure plugin is linked successfully.
发自我的 iPhone
在 2018年9月13日,下午7:20,José Carlos Schröder Júnior notifications@github.com 写道:
Not working, same problem undefined is not an object (evaluating '_reactNativeSunmiInnerPrinter2.default.printString')
I also tried usin U sample (https://github.com/januslo/react-native-sunmi-inner-printer/blob/master/examples/index.android.js) and same error.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
@juniorschroder I have tested my demo and works fine. after that, I published the v0.1.6 to the NPM with the code in the master.
@januslo, that's too weird!
I unlinked U package from my project and uninstall on npm, than I install and linked again and same thing, import SunmiInnerPrinter from 'react-native-sunmi-inner-printer'; and SunmiInnerPrinter is undefined!
So i did a test here, in U npm package, I've edited index.js and below const SunmiInnerPrinter = NativeModules.SunmiInnerPrinter; i put and console.log and ok, it's a Object, but after module.exports = SunmiInnerPrinter; in my App this turns undefined.
So, to make this work I'm using on my App this module directly from react-native NativeModules let test = NativeModules.SunmiInnerPrinter;
this works fine!
Thanks for attention!
Oh? Will do more test later
发自我的 iPhone
在 2018年9月22日,上午2:35,José Carlos Schröder Júnior notifications@github.com 写道:
@januslo, that's too weird!
I unlinked U package from my project and uninstall on npm, than I install and linked again and same thing, import SunmiInnerPrinter from 'react-native-sunmi-inner-printer'; and SunmiInnerPrinter is undefined!
So i did a test here, in U npm package, I've edited index.js and below const SunmiInnerPrinter = NativeModules.SunmiInnerPrinter; i put and console.log and ok, it's a Object, but after module.exports = SunmiInnerPrinter; in my App this turns undefined.
So, to make this work I'm using on my App this module directly from react-native NativeModules let test = NativeModules.SunmiInnerPrinter;
this works fine!
Thanks for attention!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Seems it's my fault in my demo, since I am using module.export,we need to import this module with {},as
import {SunmiInnerPrinter} from 'react-native-sunmi-inner-printer'.
REF:https://stackoverflow.com/questions/41666130/export-default-vs-module-exports-differences/41666401 You may try this.
Yap, that's works fine!
Thanks
device: https://sunmi.com/en/v1.html
So, my app was build with success, but when i'm call printString this error happens. debuggin my app: import SunmiInnerPrinter from 'react-native-sunmi-inner-printer'; console.log(SunmiInnerPrinter) - this is undefined.
Anyone can help?