Skip to content

[Bug] AnkiDroid fails to start if external storage does not exist (getExternalFilesDir is null) #13207

@mikehardy

Description

@mikehardy

Important

If you are seeing this on a new Google Pixel device:

Reproduction Steps
  1. fire up a windows machine (windows 11 VM, Android 12 emulator, verified that /sdcard/AnkiDroid did not exist - that is, it is a clean install)
  2. gradlew.bat installPlayDebug
  3. attempt to start the app after install
Expected Result

App starts up

Actual Result

NullPointerException, the wicked !! strikes again...

Sincere apologies for the screenshot of the stacktrace, it's on a VM where I can't copy/paste the text for "reasons"

image

But here's a link to the offender in attempt to make up for it:

return context.getExternalFilesDir(null)!!.absolutePath

I did get a toast saying "Device Storage Not Mounted" and the app quit, after uninstalling / reinstalling / granting storage permission

What if there is no external storage though? Should I be able to use AnkiDroid on only internal storage? That could be a valid device configuration ?

Storage config looks like this:

image

There is supposed to be a 768MB sdcard in the AVD definition but it appears it is not mounted, this shows up in logs:

StorageManagerService system_process W No primary storage defined yet; hacking together a stub

It is possible this configuration is simply invalid (are there any android devices that have no "external" storage?) as I am unable to run the storage system preferences app either (Volume external_primary not found)

But might be worth a look / some better messaging in case something like this is out in the wild.

I'll purge this AVD and try a different one

Debug info

Just one commit back on main at the moment - was built from this commit sha 4cb853c

Research

Enter an [x] character to confirm the points below:

  • I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • I have checked the manual and the FAQ and could not find a solution to my issue
  • I have searched for similar existing issues here and on the user forum
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

Metadata

Metadata

Assignees

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions