Skip to content

refactor(android): Migrate native module from Java to Kotlin #1239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 23, 2025

Conversation

subhankarmaiti
Copy link
Contributor

Summary

This pull request fully migrates the native Android implementation of the library from Java to Kotlin. This modernization effort aligns the codebase with current best practices for Android development, where Kotlin is the officially recommended language. The migration enhances code safety, readability, and maintainability without altering the module's functionality.

Key Changes

  • Complete Code Migration:

    • All .java source files within the android/src directory have been converted to their Kotlin (.kt) equivalents.
    • This includes the core module logic (A0Auth0Module), the package definition (A0Auth0Package), parsers (CredentialsParser, LocalAuthenticationOptionsParser), and architecture-specific specs (A0Auth0Spec).
  • Updated Build Configuration:

    • The android/build.gradle file has been updated to add the kotlin-android plugin and necessary dependencies like kotlin-stdlib.
    • The Android Gradle Plugin has been upgraded to a more recent version.
    • A new android/gradle.properties file has been introduced to centralize and manage versions for Kotlin, Android SDKs, and other build configurations, making them easier to update.
  • Code Refinements:

    • The new Kotlin code leverages modern language features like null safety, companion objects, and concise syntax, reducing boilerplate and potential for null-pointer exceptions.

This is a pure refactoring initiative. There are no intentional changes to the public API or the behavior of the Android native module. The primary goal is to improve the long-term health and maintainability of the codebase.

- Removed the old Java implementation of A0Auth0Module and A0Auth0Package.
- Introduced new Kotlin implementations for A0Auth0Module and A0Auth0Package.
- Converted CredentialsParser and LocalAuthenticationOptionsParser from Java to Kotlin.
- Updated A0Auth0Spec to Kotlin, maintaining the abstract structure for module methods.
- Removed deprecated Java files related to the old architecture.
- Ensured compatibility with the new architecture by implementing TurboReactPackage.
…ration and dependencies

fix(A0Auth0Module): resolve activity casting issues and simplify domain validation
@subhankarmaiti subhankarmaiti marked this pull request as ready for review July 17, 2025 04:22
@subhankarmaiti subhankarmaiti requested a review from a team as a code owner July 17, 2025 04:22
private const val INVALID_DOMAIN_URL_ERROR_CODE = "a0.invalid_domain_url"
private const val BIOMETRICS_AUTHENTICATION_ERROR_CODE = "a0.invalid_options_biometrics_authentication"
private const val LOCAL_AUTH_REQUEST_CODE = 150
const val UNKNOWN_ERROR_RESULT_CODE = 1405
Copy link
Contributor

@pmathew92 pmathew92 Jul 17, 2025

Choose a reason for hiding this comment

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

nit: lets keep the public properties and private properties ordered together

})
}

override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can delete this method ,if not being used

@subhankarmaiti subhankarmaiti merged commit 17ec667 into master Jul 23, 2025
4 checks passed
@subhankarmaiti subhankarmaiti deleted the SDK-5699-kotlin-migration branch July 23, 2025 11:37
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.

2 participants