TeamAmaze / TeamAmaze/AmazeFileManager

`java.lang.IllegalStateException: TabFragment not attached to an activity` on `TabFragment#requireMainActivity`

Open
#3,374 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

Describe the bug
I used to use Amaze 3.5.3, However, after install the newest version 3.7.2, I find a crash which annoys me a lot.

After installation, rotate the device and accept storage permission, then Amaze crashes.
However, it behaves normally on Amaze 3.5.3

To Reproduce
Steps to reproduce the behavior:

  1. install Amaze 3.7.2
  2. open Amze
  3. rotate device
  4. click "Allow Amaze to access photos,media, and files on your divice"
  5. see crash report

Expected behavior
I can still see my files and use AmazeFileManager normally

Screenshots

https://user-images.githubusercontent.com/31406320/176077657-7d361c4b-3b30-47c1-aef9-13a55b3ace4b.mp4

Smartphone (please complete the following information):

  • Device: [e.g. Google Pixel 2]
  • OS: [e.g. Android 9]
  • Rooted: [e.g. No]
  • Version: [e.g. 3.3.4]

Additional context

Issue explanation (write below this line)

Exception

  • App Name: Amaze File Manager
  • Package: com.amaze.filemanager
  • Version: 3.7.2
  • User Action: UI Error
  • Request: Application crash
  • OS: Linux Android 8.0.0 - 26
  • Device: generic_x86
  • Model: Android SDK built for x86
  • Product: sdk_gphone_x86
Crash log

java.lang.IllegalStateException: Fragment TabFragment{482657d} (0ab7c6c7-267f-4f7c-98ff-4de39ef40029) not attached to an activity.
	at androidx.fragment.app.Fragment.requireActivity(Fragment.java:928)
	at com.amaze.filemanager.ui.fragments.TabFragment.requireMainActivity(TabFragment.java:497)
	at com.amaze.filemanager.ui.fragments.TabFragment.refactorDrawerStorages(TabFragment.java:346)
	at com.amaze.filemanager.ui.activities.MainActivity.lambda$onPermissionGranted$1(MainActivity.java:512)
	at com.amaze.filemanager.ui.activities.MainActivity.$r8$lambda$p7zQEtaqRSrFGunP-GdzA6cGHkk(Unknown Source:0)
	at com.amaze.filemanager.ui.activities.MainActivity$$ExternalSyntheticLambda17.run(Unknown Source:6)
	at io.reactivex.internal.observers.CallbackCompletableObserver.onComplete(CallbackCompletableObserver.java:53)
	at io.reactivex.internal.operators.completable.CompletableObserveOn$ObserveOnCompletableObserver.run(CompletableObserveOn.java:89)
	at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
	at android.os.Handler.handleCallback(Handler.java:789)
	at android.os.Handler.dispatchMessage(Handler.java:98)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6541)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack trace in ui/fragments/TabFragment.java at requireMainActivity and refactorDrawerStorages, then inspect MainActivity.java around onPermissionGranted. Reproduce the rotation and storage-permission flow on Android 8. Done means the app does not crash after permission is granted and the file list remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.