Skip to content

fix(android): read current activity from ReactApplicationContext - #22

Open
martintreurnicht wants to merge 1 commit into
shakebugs:masterfrom
martintreurnicht:fix/android-current-activity
Open

martintreurnicht wants to merge 1 commit into
shakebugs:masterfrom
martintreurnicht:fix/android-current-activity

Conversation

@martintreurnicht

Copy link
Copy Markdown

ShakeModule.kt reads the inherited currentActivity property in four places: start, addPrivateView, removePrivateView and showNotificationsSettings. With React Native 0.88 (Expo SDK 58, Kotlin 2.2) the module no longer compiles there. On ReactContextBaseJavaModule, getCurrentActivity() is a deprecated Kotlin function, and React Native recommends reactApplicationContext.currentActivity instead. 17.2.2 built fine on React Native 0.86.3 (Kotlin 2.1.20). 18.0.0 and master still have the same four reads.

This change reads the activity from the module's ReactApplicationContext, which works on every React Native version the SDK supports. react-native-datetimepicker fixed the same break the same way (react-native-datetimepicker/datetimepicker#1002).

To reproduce: add @shakebugs/react-native-shake to a React Native 0.88 app and run ./gradlew :app:assembleDebug. The build fails in ShakeModule.kt.

We've been shipping this change as a local patch on React Native 0.88.

🤖 Generated with Claude Code

ShakeModule.kt read the inherited currentActivity property in four places,
which no longer compiles on React Native 0.88. Read it from the module's
ReactApplicationContext instead, as RN's deprecation of getCurrentActivity()
suggests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mstanic-shake

Copy link
Copy Markdown
Member

Thank you, we have applied the fix and will release the patch soon.

@martintreurnicht

Copy link
Copy Markdown
Author

Thanks! We'll drop our local patch once that release is out.

@mstanic-shake

mstanic-shake commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

@martintreurnicht 18.0.1 version is released and it should fix this issue. Let us know if it works for you now.

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