douglasjunior / react-native-easybluetooth-classic

⚛ A Library for easy implementation of Serial Bluetooth Classic on React Native (Android Only).
https://www.npmjs.com/package/easy-bluetooth-classic
MIT License
43 stars 7 forks source link

Can't found any device when application at release time #31

Open yingpengsha opened 5 years ago

yingpengsha commented 5 years ago

It's all right when application at debug time.

It's my code

   componentDidMount() {
        const config = {
            uuid: '00001101-0000-1000-8000-00805f9b34fb',
            deviceName: 'SMRM',
            bufferSize: 1024,
            characterDelimiter: '\r\n',
        }
        EasyBluetooth.init(config)
            .then((config) => {
                console.log('config done!')
            })
            .catch((ex) => {
                console.warn(ex)
            })
        this.onDataReadEvent = EasyBluetooth.addOnDataReadListener(this.onDataRead.bind(this))
    }

    scan=async () => {
        Toast.loading('搜索蓝牙中', 20)
        await this.setState({ scanning: true })
        EasyBluetooth.startScan()
            .then((devices) => {
                console.warn('all devices found:')
                console.log(devices)
                this.setState({ devices, scanning: false })
                Toast.hide()
            })
            .catch((ex) => {
                console.warn(ex)
            })
    }

It's logcat

debug version

2019-04-19 15:25:05.914 10739-11616/com.demo I/ReactNativeJS: config done!

release version

2019-04-19 15:26:41.634 14226-14272/? W/ReactNativeJS: { [Error: BluetoothService has not been configured. Call ReactNativeEasyBluetooth.init(config).] framesToPop: 1, code: 'EUNSPECIFIED' }
douglasjunior commented 5 years ago

Are you using proguard?

yingpengsha commented 5 years ago

Are you using proguard?

Yes I am,Is there anything I should pay attention to?

douglasjunior commented 5 years ago

I guess so, try to ignore everything inside com.github.douglasjunior package.

yingpengsha commented 5 years ago

I inserted -keep class io.github.douglasjunior.** or -keep class com.github.douglasjunior.** into the file,nothing happened. But I just close the proguard,The mistake is gone.