Issues with Branch, ClassNotFoundException

#1

Hi,

I’m trying to use Branch, and I’ve got it at least to the point where it opens the app, standalone, on Android. Built via exp build.

But nothing happens, and I had a look at logcat, which says:

10-18 23:15:07.278 31433 31433 E g       : java.lang.ClassNotFoundException: abi21_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
10-18 23:15:07.278 31433 31433 E g       : Runtime exception in RNObject: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference

Before that it also says

10-18 23:15:06.724 15229 15229 W cr_GoogleAuth: Bad URI 'intent://open?link_click_id=309<redacted>234087#Intent;scheme=myappScheme://+;package=com.mycompany.mypackage;S.browser_fallback_url=https%3A%2F%2Fsomefallbacksite.com%3F_branch_match_id%3D30<redacted>34087;S.market_referrer=link_click_id-3098<redacted>87;B.branch_intent=true;end'
10-18 23:15:06.733  1206  2064 I ActivityManager: START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myappScheme: flg=0x10000000 pkg=com.mycompany.mypackage cmp=com.mycompany.mypackage/host.exp.exponent.LauncherActivity (has extras)} from uid 10093 pid 15229 on display 0

Although not sure if related.

I added the following code, alternately in plain App.js and in componentDidMount deeper inside:

Tried in App.js:

DangerZone.Branch.subscribe((bundle) => {
  if (bundle && bundle.params && !bundle.error) {
    Alert.alert('Opened Branch link', JSON.stringify(bundle.params, null, 2));
  }
});

Tried where I wanted it to be:

    this.unsubscribeFromBranch = DangerZone.Branch.subscribe(({ error, params }) => {
      if (error) {
        console.error(`Error from Branch: ${error}`);
        return;
      }

      console.log(`Branch params: ${JSON.stringify(params)}`);

      if (!params['+clicked_branch_link']) return;

      // Get title and url for route
      // const title = params.$og_title;
      const url = params.$canonical_url;
      this.setState({ branch: JSON.stringify(params) });

      // const image = params.$og_image_url;

      // Now push the view for this URL
      // this.navigator.push({ title, url, image }); // ??????????
      const navigationAction = NavigationActions.navigate({ routeName: url, params });
      this.props.dispatch(navigationAction);
    });

I’m not sure where to go from here. Do you have any working examples, or some hints at what to do?

In a related note, the Linking.initialUrl is never myscheme://<whatever> unless I launch a link with just myscheme://?<something>=<something> specifically with a question-mark and no, well, uri, just queryparams. Is this also expected?

Best regards,
Aslak

4 Likes
#2

DangerZone is named such because things code there have bugs there, I think you might have stumbled on one because look like the Java side is hitting a null pointer.

Is the code posted enough to reproduce?

#3

Hi Edgar,

I’m not sure you need to add any code, but if so yes, that should do it. I get the below by just launching the app, built with build:android. Tested with expo@22.

$ ./node_modules/xdl/binaries/windows/adb/adb.exe logcat | grep -A 1 abi22_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
10-22 01:02:48.597 11666 11666 E g       : java.lang.ClassNotFoundException: abi22_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
10-22 01:02:48.597 11666 11666 E g       : Runtime exception in RNObject: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference

Best regards,
Aslak

#4

Hi @lastcall, could you solve this issue? We are experiencing a very similar problem as described in the following post Branch subscribe not working

01-22 10:43:14.875 27690 27690 E h       : java.lang.ClassNotFoundException: abi24_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
01-22 10:43:14.895 27690 27690 E h       : Runtime exception in RNObject when calling method initSession: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference
01-22 10:43:15.365 27690 27690 E h       : java.lang.ClassNotFoundException: abi24_0_0.com.facebook.soloader.SoLoader
01-22 10:43:15.365 27690 27690 E h       : Runtime exception in RNObject when calling method init: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference

Thanks in advance

Branch subscribe not working
#5

We finally decided to set up a new pure React Native project with the React-Native-Branch module which works now. Sad that we could not keep on using Expo. Let me know when this issue is fixed and Branch for expo is production ready.
Best,
Julius

#6

We are experiencing this issue as well. Any update on a workaround? Or a working example of tracking attribution params?

#7

I’m having the same issue on Android only, standalone Expo v25. iOS works great. Could be related to this issue with the base Branch SDK.

#8

Hi, we’re having the same issues, on iOS is working correctly: we’re receiving events when subscribing with Branch.subscription(...), but on Android we’re getting the same Null pointer exception on the ** RNBranchModule**.

It could be related to the react-native-branch version used on expo? It seems like the 2.0.0-beta.3 is quite old :sweat_smile:

One workaround I found is to use the getLatestReferringParams and check the +click_timestamp param. But this will only work with Branch links.

EDIT: as the issue shared by coreyac. The getLatestReferringParams workaround will only work after closing, opening the app. So this is still not a good solution for the problem.

1 Like
#9

I am getting similar issue for v25.

04-04 11:41:42.319 30352 30352 E i       : java.lang.ClassNotFoundException: abi25_0_0.host.exp.exponent.modules.api.branch.RNBranchModule
04-04 11:41:42.319 30352 30352 E i       : Runtime exception in RNObject when calling method initSession: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Method[] java.lang.Class.getMethods()' on a null object reference

Anyone got Branch to work for Android and iOS without detaching?

Looking at the versions, it looks like Expo’s branch is about 1 year behind the latest Branch version. Is Branch likely to see an update for Expo? Or is Expo moving forward with some other tools like Firebase?

#12

This is what I ended up going with… it seems to work for my purposes, but would still love to know if there’s a better way.

`async handleInvite(params){
//Alert.alert( ‘Params’, JSON.stringify(params), [ {text: ‘Ok’, onPress: () => console.warn(’ ')},] )
if(params != ‘{}’ && params["+clicked_branch_link"] && params.singleProfile != undefined){
Actions.login();
}
}

async componentDidMount() {
if(Constants.appOwnership != ‘expo’) {
AppState.addEventListener(‘change’, (state) => {
if (state === ‘active’) {
//console.warn(‘state active’);
setTimeout(() => {Expo.DangerZone.Branch.getLatestReferringParams().then(params => this.handleInvite(params))}, 500);
}
});
}
}`

1 Like
#13

Yeah this is what we diagnosed the issue was as well (that the Branch version is so far behind on expo)

#14

any news on this? :sweat_smile:

closed #15

This topic was automatically closed after 14 days. New replies are no longer allowed.

e: For those still encountering this problem, we plan to update react-native-branch in sdk 28.