Skip to content

docs: correct the getting-started guide against the GA API surface - #2546

Closed
demolaf wants to merge 1 commit into
masterfrom
docs/getting-started-ga-api
Closed

demolaf wants to merge 1 commit into
masterfrom
docs/getting-started-ga-api

Conversation

@demolaf

@demolaf demolaf commented Nov 2, 2026

Copy link
Copy Markdown
Member

Four defects in this guide stop a reader who copies it from compiling, and the install block never mentions Compose while every snippet calls setContent.

Changes

  • Resolve AuthUITheme.fromMaterialTheme() and AuthUITheme.Adaptive above authUIConfiguration { }, which is a plain fun, not inline, so neither @Composable read compiles inside it.
  • Correct the Facebook artifact to com.facebook.android:facebook-login:18.3.0, which is what the build resolves. facebook-android-sdk does not exist.
  • Add the Compose compiler plugin, compose-bom, compose-ui and material3 to the install block, since :auth declares its own Compose dependencies as implementation.
  • Add minimum requirements to Before you begin, mirroring auth/README.md.
  • Replace the isSignedIn() gate with authStateFlow().collectAsState. isSignedIn() is a plain currentUser != null read with no snapshot backing, so the UI never left the auth screen.
  • Hold AuthFlowController as a field, dispose it in onDestroy(), and register the launcher as a property initializer rather than after STARTED.

No library version is touched: the 10.0.0-beta05 pin and the beta banner belong to a separate doc pass.


Maintainer note: Fixes internal CPRN-616

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GETTING_STARTED.md documentation to align with modern Android development standards, including Jetpack Compose, Kotlin 2.0+, and reactive state collection. Key improvements include extracting @composable theme getters from non-inline lambdas and demonstrating the proper lifecycle management of AuthFlowController in Activities. Feedback focuses on optimizing Compose performance by wrapping authUIConfiguration and the rememberAuthConfiguration helper in remember blocks to avoid unnecessary recompositions, as well as guarding the Activity-based intent launch with a savedInstanceState == null check to prevent relaunching on configuration changes.

Comment thread GETTING_STARTED.md
Comment on lines 152 to +154
val configuration = authUIConfiguration {
context = applicationContext
theme = AuthUITheme.fromMaterialTheme()
theme = authTheme

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The configuration is created directly inside the setContent block without being wrapped in remember. Since AuthUIConfiguration is an unstable type, creating a new instance on every recomposition will cause FirebaseAuthScreen to recompose unnecessarily. It is highly recommended to wrap the authUIConfiguration block in remember(authTheme) to cache the configuration across recompositions.

Comment thread GETTING_STARTED.md
Comment on lines +231 to 238
return authUIConfiguration {
context = appContext
providers {
provider(AuthProvider.Email())
provider(AuthProvider.Google(scopes = listOf("email"), serverClientId = null))
}
theme = authTheme
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The helper function is named rememberAuthConfiguration, but it does not actually use Compose's remember API. Without remember, a new AuthUIConfiguration instance will be created on every recomposition, which can trigger unnecessary recompositions in child composables (like FirebaseAuthScreen) because AuthUIConfiguration is not a stable type. Wrapping the configuration builder in remember ensures it is cached across recompositions.

Suggested change
return authUIConfiguration {
context = appContext
providers {
provider(AuthProvider.Email())
provider(AuthProvider.Google(scopes = listOf("email"), serverClientId = null))
}
theme = authTheme
}
return remember(appContext, authTheme) {
authUIConfiguration {
context = appContext
providers {
provider(AuthProvider.Email())
provider(AuthProvider.Google(scopes = listOf("email"), serverClientId = null))
}
theme = authTheme
}
}

Comment thread GETTING_STARTED.md
Comment on lines +288 to +289
authController = FirebaseAuthUI.getInstance().createAuthFlow(configuration)
authLauncher.launch(authController.createIntent(this))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Launching the activity result launcher directly in onCreate without checking savedInstanceState == null will cause the authentication flow to be launched again whenever the activity is recreated (such as during a device rotation). Checking if savedInstanceState is null ensures that the flow is only launched on the initial creation of the activity.

Suggested change
authController = FirebaseAuthUI.getInstance().createAuthFlow(configuration)
authLauncher.launch(authController.createIntent(this))
authController = FirebaseAuthUI.getInstance().createAuthFlow(configuration)
if (savedInstanceState == null) {
authLauncher.launch(authController.createIntent(this))
}

@demolaf

demolaf commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Folded into #2544. The open review threads are addressed there: rememberAuthConfiguration now uses remember, and the createAuthFlow example only launches on first creation. Building the configuration in setContent without remember is left as is, matching the auth README.

@demolaf demolaf closed this Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Nov 3, 2026
@demolaf
demolaf deleted the docs/getting-started-ga-api branch November 3, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant