Unable to deploy to Android, `com.epicgames.unreal.RemoteFileManagerService.onStartCommand` NPE from `getExternalFilesDir`

I have a Pixel 7 that I am not able to deploy local Development builds to.

Here’s trimmed the command output from Install_ProjectNameClient_universal.bat:

B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe uninstall com.spryfox.projectname
Success
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe install ProjectNameClient_universal.apk
Performing Streamed Install
Success
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm list packages com.spryfox.projectname
package:com.spryfox.projectname
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm grant com.spryfox.projectname android.permission.FOREGROUND_SERVICE 1>nul 2>&1
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm grant com.spryfox.projectname android.permission.FOREGROUND_SERVICE_DATA_SYNC 1>nul 2>&1
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm grant com.spryfox.projectname android.permission.POST_NOTIFICATIONS 1>nul 2>&1
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm grant com.spryfox.projectname android.permission.READ_EXTERNAL_STORAGE 1>nul 2>&1
B:\proj\LocalBuilds\Android>B:\proj\Tools\Binaries\android\sdk\platform-tools\adb.exe shell pm grant com.spryfox.projectname android.permission.WRITE_EXTERNAL_STORAGE 1>nul 2>&1
B:\proj\LocalBuilds\Android>.\win-x64\UnrealAndroidFileTool.exe -p com.spryfox.projectname -k <key> push main.1.com.spryfox.projectname.Client.obb "^mainobb"
Trying to start file server com.spryfox.projectname
Did not find a bind listener
Unable to connect to <device>

Here’s relevant logcat output:

D UEFS  : RemoteFileManagerActivity cmd: start, package = com.spryfox.projectname
D UEFS  : onStartCommand 1 received start command com.spryfox.projectname
E UEFS  : External storage state is mounted
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.spryfox.projectname, PID: 15644
E AndroidRuntime: java.lang.RuntimeException: Unable to start service com.epicgames.unreal.RemoteFileManagerService@242a339 with Intent { act=com.epicgames.unreal.RemoteFileManager.intent.COMMAND2 xflg=0x4 cmp=com.spryfox.projectname/com.epicgames.unreal.RemoteFileManagerService (has extras) }
E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5527)
E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2654)
E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:110)
E AndroidRuntime:    at android.os.Looper.dispatchMessage(Looper.java:315)
E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:251)
E AndroidRuntime:    at android.os.Looper.loop(Looper.java:349)
E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:9041)
E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
E AndroidRuntime:    at com.epicgames.unreal.RemoteFileManagerService.onStartCommand(RemoteFileManagerService.java:165)
E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5511)
E AndroidRuntime:    ... 10 more

“External storage state is mounted” is logging I added to verify Environment.getExternalStorageState(). Any ideas what could be going wrong?

Steps to Reproduce

  1. Build & package an Android project
  2. Run LocalBuilds/Android/Install_ProjectNameClient_universal.bat

Other members of the team are able to deploy with the same steps, so something must be off with the device or my local setup. We use the same version of the Android SDK & NDK, as those tools are kept in Perforce. According to the docs for `getExternalFilesDir(null)` (which is what is returning null) (https://developer.android.com/reference/android/content/Context.html\#getExternalFilesDir(java.lang.String)), it should only be returning null “if shared storage is not currently available”, but “Environment.getExternalStorageState()” is returning “Environment.MEDIA_MOUNTED”, so that shouldn’t be the issue.

I’ve made sure that the USB connection is set to charging only (so no mass storage mounting), and attempted rebooting the device and upgrading the OS.

Hi Jorgen,

I assume the Pixel 7 device is running Android 15? Is that the case for other developers that aren’t experiencing the issue? Does granting the WRITE_EXTERNAL_STORAGE permission have any effect here? (adb shell pm grant <package name> WRITE_EXTERNAL_STORAGE)

Best regards

Hi Jorgen,

That was going to be my last resort suggestions. Glad that it seems to have resolved the issue for that device. I assume it was running stock Android distro.

Best regards.

Thanks Jorgen, I guess this will remain a mystery but glad that the factory reset resolved the issue.

Best regards.

Granting `WRITE_EXTERNAL_STORAGE` did not have any effect. In order to unblock this device, after much investigation, I attempted a factory reset, and it is now able to boot the application again, so I’m not sure what had gotten broken.

Yep, stock Android updated to the latest system software.