AppAuth-Android icon indicating copy to clipboard operation
AppAuth-Android copied to clipboard

Unable to start activity ComponentInfo{com.example.my_app/net.openid.appauth.RedirectUriReceiverActivity}

Open gargVader opened this issue 1 year ago • 2 comments

Configuration

  • Version: 0.11.1
  • Integration: Kotlin
  • Identity provider: Google

Description

After authorizing, when the app tries to launch the RedirectUriReceiverActivity, I get the following error. Error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.my_app/net.openid.appauth.RedirectUriReceiverActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

While creating AuthorizationRequest, I set the redirect url as

AuthorizationRequest.Builder(
            authServiceConfig,
            MY_CLIENT_ID_FROM_GOOGLE_CONSOLE,  
            ResponseTypeValues.CODE,  
            Uri.parse("com.googleusercontent.apps.MY_CLIENT_ID_FROM_GOOGLE_CONSOLE:/oauthredirect") // redirect URI
        )

My AndroidManifest.xml

        <activity android:name="net.openid.appauth.RedirectUriReceiverActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="com.googleusercontent.apps.MY_CLIENT_ID_FROM_GOOGLE_CONSOLE"
                    android:path="/oauthredirect"/>
            </intent-filter>
        </activity>

In my build.gradle.kts

manifestPlaceholders["appAuthRedirectScheme"] = "com.googleusercontent.apps.MY_CLIENT_ID_FROM_GOOGLE_CONSOLE"

I launch the intent from the AuthorizationService.getAuthorizationRequestIntent() using the following launcher in my composable.

val authorizationLauncher = rememberLauncherForActivityResult(
        contract = ActivityResultContracts.StartActivityForResult(),
        onResult = {}
    )

gargVader avatar Nov 23 '23 18:11 gargVader

I'm not sure if this is helpful, but for android 14, I managed to resolve the same error message by following the comments written in this issue (#977)

Zerro97 avatar Dec 18 '23 03:12 Zerro97

The problems can indeed be solved with a hint from #977 : Add android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar" (or any other appcompat-theme) to the RedirectUriReceiverActivity declaration.

vhschlenker avatar Jan 11 '24 16:01 vhschlenker