TeamAmaze / TeamAmaze/AmazeFileManager
`java.lang.IllegalStateException: TabFragment not attached to an activity` on `TabFragment#requireMainActivity`
Nobody has claimed this yet.
- 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:
- install Amaze 3.7.2
- open Amze
- rotate device
- click "Allow Amaze to access photos,media, and files on your divice"
- see crash report
Expected behavior
I can still see my files and use AmazeFileManager normally
Screenshots
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
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 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