question

matheus.andrade@skyvu.net avatar image
matheus.andrade@skyvu.net asked

PlayFabAndroidPlugin restarting after closing the app

I was getting some "Your app has stopped working" after force closing my app. Checking logcat, I noticed that right after killing my game's process, a restart of the "com.playfab.unityplugin.PlayFabUnityAndroidPlugin" process was scheduled by the ActivityManager, which was causing a crash right after. Logcat (edited):

11-17 12:10:45.249 801 5220 I ActivityManager: Process com.mycompany.myapp (pid 26860) has died
11-17 12:10:45.249 801 5220 W ActivityManager: Scheduling restart of crashed service com.mycompany.myapp/com.playfab.unityplugin.PlayFabUnityAndroidPlugin in 5812ms
11-17 12:10:51.129 801 814 I ActivityManager: Start proc 26958:com.mycompany.myapp/u0a432 for service com.mycompany.myapp/com.playfab.unityplugin.PlayFabUnityAndroidPlugin

Then the actual crash:
Caused by: java.lang.RuntimeException: Unable to create service com.playfab.unityplugin.PlayFabUnityAndroidPlugin: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference

The crash is expected since we don't have the Google Services anymore (the app was killed), but should the PlayFabAndroidPlugin be restarted when I close my app?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Matheus,
This is the default Android behavior when a service crashes. The service is left open for listening for and handling push notifications. If you are no longer using Push / GCM, then you can feel free to remove the PlayFab plugins from your Unity project and delete the references from the AndroidManifest.

Let me know if you have further questions or run into additional issues.

Happy Developing,
Zac

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

matheus.andrade@skyvu.net avatar image
matheus.andrade@skyvu.net answered

Hi Zac,

I am still using the PlayFabAndroidPlugin for push notifications.

In that case, should the service keep the Google Services plugin loaded? It looks like it's trying to access it but it's unloaded.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Matheus,
So I see that you are looking to use PushNotificaiton. That being said you will need to keep all of the plugins in your project and the details in the manifest.

Based on your issue, I do not believe you have the most up-to-date plugin. I just updated the Unity SDK sample project to include the most recent .jar and manifest.

You can find the core files here: https://github.com/PlayFab/UnitySDK/tree/master/UnityAndroidPluginSource/playfabunityplugin/release

And the updated client sample project here: https://github.com/PlayFab/UnitySDK/tree/master/PlayFabClientSample

After you update, if you are still having issues, give me some more details on:
* What device and Android version is this?
* Does this crash happen consistently; if so, what are the exact steps to reproduce the crash?
* Can you provide the whole crash dump from LogCat?
* Are you using any additional Android plugins?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.