[android] Unable to add window -- token null is not valid; is your activity running? in Debug
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Description
When starting a project in debug mode, android application crashes with an error
FATAL EXCEPTION: main
Process: com.myproject, PID: 18039
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1312)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:405)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1581)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1347)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1313)
at com.facebook.react.devsupport.DefaultDevLoadingViewImplementation.showInternal(DefaultDevLoadingViewImplementation.java:131)
at com.facebook.react.devsupport.DefaultDevLoadingViewImplementation.-$$Nest$mshowInternal(Unknown Source:0)
at com.facebook.react.devsupport.DefaultDevLoadingViewImplementation$1.run(DefaultDevLoadingViewImplementation.java:56)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
React Native Version
0.72.6
Output of npx react-native info
System:
OS: macOS 14.0
CPU: (8) arm64 Apple M1
Memory: 82.39 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 16.17.0
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: /opt/homebrew/bin/yarn
npm: Not Found
Watchman: Not Found
Managers:
CocoaPods:
version: 1.12.1
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 15.0.1/15A507
path: /usr/bin/xcodebuild
Languages:
Java:
version: 18.0.2
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.6
wanted: 0.72.6
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to reproduce
- Init project
- Implement this code to MainActivity.kt
val CUSTOM_EXTRA_NAME = "RELAUNCHED"
override fun onCreate(savedInstanceState: Bundle?) {
if (!intent.getBooleanExtra(CUSTOM_EXTRA_NAME, false)) {
this.finish()
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(CUSTOM_EXTRA_NAME, true);
startActivity(intent);
}
super.onCreate(null)
}
- Got error
Snack, screenshot, or link to a repository
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MainActivity.kt reproduction in the linked repository and run a debug launch using React Native 0.72.6. Trace the reported path through DefaultDevLoadingViewImplementation and compare it with the custom activity restart sequence; done means establishing a scoped, reproducible framework issue or documenting why the report does not identify a framework change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100