codemotionapps/react-native-help-scout

Beacon is not initialised - SDKInitException

omprakashnitdgp opened this issue · 5 comments

I am initialising beacon in the application class OnCreate method with correct beacon_id.
However, it is throwing error
com.helpscout.beacon.SDKInitException: Beacon not initialized. If you have disabled auto initialization via manifest metadata, ensure Beacon is manually init using Beacon.Builder().withContext(context)

Auto Initialisation is not disabled from the Manifest file.

IOS working fine with the same code base.
I tried to initialized Beacon from both Native & react-native JS side but each time it is throwing SDKInitException

Screenshot_1596544222

I am initialising beacon in the application class OnCreate method with correct beacon_id.

You're initializing Beacon in Java/Kotlin?

I tried in different ways but each time throwing same Beacon initialization error.

Method 1.

import { Beacon } from 'react-native-help-scout'

Using this npm library, I tried to initialised in componentDidMount (Beacon.init(beacon_id)) but on page load its throws error.

This approach working fine on IOS platform but an error on android platform

Method 2.

Based on HelpScout documentation, I tried to integrate the android SDK & initialized beacon in Application Class OnCreate() method. I am getting the same initialization here also.

dependencies {
  implementation "com.helpscout:beacon-core:$beaconVersion"
  implementation "com.helpscout:beacon-ui:$beaconVersion"
}
Beacon beacon = new Beacon.Builder()
  .withBeaconId("YOUR_BEACON_ID_HERE")       
  .build();

https://developer.helpscout.com/beacon-2/android/

Any quick response is really helpful for me @DimitarNestorov

I just created a brand new React Native project and added react-native-help-scout and it seems to work fine. Try with the latest version of Beacon. To do so open android/app/build.gradle and add rootProject.ext.helpscoutBeacon = "2.1.2" before apply from: "../../node_modules/react-native/react.gradle". You don't need to call Beacon.init on componentDidMount, you can do it outside of any component. Don't use method 2.

No luck @DimitarNestorov Any react-native version issue

I am using below environment

System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
    Memory: 21.83 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 20.0, macOS 10.16, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3, 29.0.0, 29.0.2, 29.0.3
      System Images: android-23 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 12.0/12A6159 - /usr/bin/xcodebuild
  npmPackages:
    @react-native-community/cli: ^4.1.0 => 4.10.1 
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

Also Android Minimum API level 21 and target API level 29

Applied your steps but getting the same error.
After that, I am initializing Beacon.init(beacon_id) but not working for me

Can you please explain in details what is going on inside your project

Thanks

Screenshot 2020-08-10 at 9 57 17 AM
Screenshot 2020-08-10 at 9 56 34 AM

I can't reproduce this error myself. I can help if you make a small example repo where you can reproduce it. Do you have the same error if you build your app on another machine?