Skip to content

fix: use older lifecycle APIs for RN 0.76 compatibility [Android]#3920

Closed
fractalscape13 wants to merge 1 commit into
rnmapbox:mainfrom
fractalscape13:fix-rn076-lifecycle-compatibility
Closed

fix: use older lifecycle APIs for RN 0.76 compatibility [Android]#3920
fractalscape13 wants to merge 1 commit into
rnmapbox:mainfrom
fractalscape13:fix-rn076-lifecycle-compatibility

Conversation

@fractalscape13

Copy link
Copy Markdown
  • Replace setViewTreeLifecycleOwner with ViewTreeLifecycleOwner.set()
  • Use getLifecycle() method instead of lifecycle property

Description

Fixes #3909

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

- Replace setViewTreeLifecycleOwner with ViewTreeLifecycleOwner.set()
- Use getLifecycle() method instead of lifecycle property

Fixes rnmapbox#3909
@fractalscape13 fractalscape13 temporarily deployed to CI with Mapbox Tokens August 8, 2025 17:22 — with GitHub Actions Inactive
@fractalscape13 fractalscape13 temporarily deployed to CI with Mapbox Tokens August 8, 2025 17:22 — with GitHub Actions Inactive
@fractalscape13 fractalscape13 temporarily deployed to CI with Mapbox Tokens August 8, 2025 17:22 — with GitHub Actions Inactive
@fractalscape13 fractalscape13 temporarily deployed to CI with Mapbox Tokens August 8, 2025 17:22 — with GitHub Actions Inactive
@fractalscape13 fractalscape13 changed the title fix: use older lifecycle APIs for RN 0.76 compatibility fix: use older lifecycle APIs for RN 0.76 compatibility [Android] Aug 8, 2025
@mfazekas

mfazekas commented Aug 9, 2025

Copy link
Copy Markdown
Contributor

@fractalscape13 thanks much for the PR.

Ideally we should be using v25 and src/main/lifecycle-compat/v25 for rn 0.76 which should have the old methods

                def targetSdk = safeExtGet("targetSdkVersion", 28)
                if (targetSdk >= 35) {
                    java.srcDirs += 'src/main/lifecycle-compat/v26'
                } else {
                    java.srcDirs += 'src/main/lifecycle-compat/v25'
                }

Can you add a logger line there:

                    logger.error("My targetSdk: ${targetSdk}")

@mfazekas

mfazekas commented Aug 9, 2025

Copy link
Copy Markdown
Contributor

@fractalscape13 see #3922

@fractalscape13

Copy link
Copy Markdown
Author

good to close this PR?

@mfazekas

mfazekas commented Aug 9, 2025

Copy link
Copy Markdown
Contributor

Hopefully a better fix is: #3922

@mfazekas mfazekas closed this Aug 9, 2025
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.

[Bug]: 10.1.40 Android build fails on RN 0.76 due to lifecycle compatibility issues in v26 LifecycleCompat.kt

2 participants