AppAuth-Android
AppAuth-Android copied to clipboard
Unable to start activity ComponentInfo{com.example.my_app/net.openid.appauth.RedirectUriReceiverActivity}
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 = {}
)
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)
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.