react-native-auth0: Could not invoke A0Auth.showUrl

I followed the quick start for react-native. Now I’m trying to show the login page with auth0.webAuth .authorize({ scope: 'openid email', audience: 'https://ramtin.auth0.com/userinfo' }) .then(credentials => console.log(credentials)) .catch(error => console.log(error));

But I’m getting “Could not invoke A0Auth.showUrl” error

“react-native”: “0.44.0”, “react-native-auth0”: “^1.0.3”,

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 35 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I ran into this issue previously and concluded that it was due to the fact that launchUrl wasn’t added until Android SDK 25 so I assumed that I would need customtabs support library 25 or newer.

To get around this without tweaking files in node_modules I updated the build.gradle in the root of my project to use the customtabs support library 25.0.1 whenever customtabs support library < 25 is being used

I did this by adding the following to my build.gradle file

allprojects {
    configurations.all {
        resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
                if (details.requested.group == 'com.android.support' && details.requested.name == 'customtabs') {
                    def launchUrlIntoducedVersion = 25
                    def majorVersion = details.requested.version.tokenize('.')[0].toInteger()

                    if (majorVersion < launchUrlIntoducedVersion) {
                        details.useVersion "25.0.1"
                    }
                }
            }
        }
    }
}

Hi

I also have this issue, and almost same as @ronitslyper 's method, I change build.gradle file, but instead of changing every linked-in libraries, I only change node_modules/react-native-auth0/android/build.gradle

from

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile 'com.android.support:customtabs:23.3.0'
}

change to

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile 'com.android.support:customtabs:23.0.1'
}

and that’s it, I open webauth page successfully, although I don’t know why ~ lol

I’ve the same problem too.

The error message is a little misleading in fact because the code where it crashes is this one:

if (activity == null) {
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(activity, Uri.parse(url));
} else {
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    getReactApplicationContext().startActivity(intent);
}

So we could think that the problem is in the second to last line getReactApplicationContext().startActivity(intent); since the error message is talking about a missing startActivity method. But it’s not.

In reality, if we invert the if condition, it kind of fixes the bug. Try replacing the lines above with:

final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
getReactApplicationContext().startActivity(intent);

and the bug is gone.

I’ve found a stack overflow question that matches this same bugs here

It suggests to bump the support SDK versions to 25.1.0

But as soon as you do this, you got a new error which this time leads to the real function which is launchUrl.

NoSuchMethodError: No virtual method launchUrl

As referred here, this method is available only since API 25.0.0 so it could explain the problem (or not).

Several SDK had this last bug too (Firebase, Spotify and others)

After several tests, I didn’t find a way to fix this other than the one above which skip the CustomTabsIntent all together

Anyway, hope these information help solving this issue!