Lock.Android: IllegalStateException in GoogleIdentityProvider.onPermissionsRequireExplanation

Hi,

We upgraded to 1.17.0 and are having a major problem with the native Google authentication. We thought we were using the textbook integration :

// setup Auth0 and the native Google integration
ParameterBuilder paramsBuilder = ParameterBuilder.newBuilder();
String scope = ParameterBuilder.SCOPE_OFFLINE_ACCESS + " email";
Map<String, Object> parameters = paramsBuilder.setScope(scope).asDictionary();

LockContext.configureLock(
        new Lock.Builder()
                .loadFromApplication(this)
                .withIdentityProvider(Strategies.GooglePlus, new GoogleIdentityProvider(this))
                .authenticationParameters(parameters)
);

When a user uses the Google authentication button, the native integration correctly asks for permission to access the contacts, then if the user cancels that request, all future use of the Google auth button will crash the app with this stacktrace :

08-18 22:55:40.078 24786-24786/<REDACTED> E/AndroidRuntime: FATAL EXCEPTION: main
                                                              Process: <REDACTED>, PID: 24786
                                                              java.lang.RuntimeException: Could not dispatch event: class com.auth0.lock.event.IdentityProviderAuthenticationRequestEvent to handler [EventHandler public void com.auth0.lock.LockActivity.onIdentityProviderAuthentication(com.auth0.lock.event.IdentityProviderAuthenticationRequestEvent)]: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                  at com.squareup.otto.Bus.throwRuntimeException(Bus.java:456)
                                                                  at com.squareup.otto.Bus.dispatch(Bus.java:386)
                                                                  at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367)
                                                                  at com.squareup.otto.Bus.post(Bus.java:336)
                                                                  at com.auth0.lock.fragment.SmallSocialListFragment$1.onItemClick(SmallSocialListFragment.java:84)
                                                                  at android.widget.AdapterView.performItemClick(AdapterView.java:310)
                                                                  at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
                                                                  at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066)
                                                                  at android.widget.AbsListView$3.run(AbsListView.java:3903)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                               Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                  at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:343)
                                                                  at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
                                                                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:277)
                                                                  at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:80)
                                                                  at android.support.v7.app.AlertController.installContent(AlertController.java:214)
                                                                  at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)
                                                                  at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
                                                                  at android.app.Dialog.show(Dialog.java:295)
                                                                  at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:953)
                                                                  at com.auth0.google.GoogleIdentityProvider.onPermissionsRequireExplanation(GoogleIdentityProvider.java:97)
                                                                  at com.auth0.identity.AuthorizedIdentityProvider.checkPermissions(AuthorizedIdentityProvider.java:156)
                                                                  at com.auth0.identity.AuthorizedIdentityProvider.start(AuthorizedIdentityProvider.java:72)
                                                                  at com.auth0.lock.LockActivity.onIdentityProviderAuthentication(LockActivity.java:296)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89)
                                                                  at com.squareup.otto.Bus.dispatch(Bus.java:384)
                                                                  at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367) 
                                                                  at com.squareup.otto.Bus.post(Bus.java:336) 
                                                                  at com.auth0.lock.fragment.SmallSocialListFragment$1.onItemClick(SmallSocialListFragment.java:84) 
                                                                  at android.widget.AdapterView.performItemClick(AdapterView.java:310) 
                                                                  at android.widget.AbsListView.performItemClick(AbsListView.java:1145) 
                                                                  at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066) 
                                                                  at android.widget.AbsListView$3.run(AbsListView.java:3903) 
                                                                  at android.os.Handler.handleCallback(Handler.java:739) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                  at android.os.Looper.loop(Looper.java:148) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

This is on a Nexus 5, Android 6.0.1, in an app with these settings :

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
...

Gradle : 2.14.1 Android Plugin : com.android.tools.build:gradle:2.1.3

Debugging a little bit this issue, as the AppCompat dialog builder is using the context from the application, it’s true that there is no theme. But the issue should not be there, as we got the code from the Auth0 sample code which also uses the application instance to build the GoogleIdentityProvider.

Happy to provide more info if needed. Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@pmq will be officially fixed when that last pr ☝️ is merged and released