Android crash on startup due to PAD implementation

We are currently unable to run builds on Android due to Unity’s built-in PAD implementation crashing the app on startup. This was purportedly fixed in Unity 2023.1.0a6, but no backporting of this fix to past LTS versions has occurred. However this may not matter as the the error has regressed in later version Unity 2023.1.6f1. This occurs for us currently on Unity 2022.3.2f1.

The issue as described here is that the PAD implementation has been only been partially updated for breaking changes in Google Play APIs and the remaining un-migrated portions are causing a crash on startup.

Google Reported Cause

Android Logcat Error
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime FATAL EXCEPTION: AssetPackBackgroundExecutor
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime Process: com.company.app, PID: 19126
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/tasks/Tasks;
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at com.google.android.play.core.assetpacks.p2.e(Unknown Source:15)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at com.google.android.play.core.assetpacks.a4.m(Unknown Source:14)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at com.google.android.play.core.assetpacks.x3.run(Unknown Source:2)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime at java.lang.Thread.run(Thread.java:1012)
2023/07/26 14:50:53.456 19126 19152 Error AndroidRuntime Caused by: java.lang.ClassNotFoundException: com.google.android.gms.tasks.Tasks

Configuration
Unity Version: 2022.3.2f1
Platform: Android
Min API Level: 26
Max API Level: 33
Scripting Backend: il2cpp
API Compatibility Level: .Net Standard 2.1
Target Architecture: ARM64
Split Application Binary: Enabled
Build App Bundle: Enabled
Minify: Enabled for Release and Debug
Plugins:

  • ExternalDependencyManager v1.2.175

  • PreciseLocale v1.5

  • OpenCoding Console v2.8.0

Packages:

  • com.yasirkula.androidruntimepermissions v1.1.6

  • com.yasirkula.nativecamera v1.3.7

  • com.yasirkula.nativegallery v1.7.2

  • com.ptc.vuforia.engine v10.16.3

  • com.unity.xr.arcore v5.0.6

  • com.unity.purchasing v4.9.3

Troubleshooting
Steps I’ve taken to troubleshoot are:

  • Add proguard stripping protections for com.google.android.gms in the off chance it was a stripping issue, but since the root cause is attempting to use an API that’s not present this likely isn’t a good solution.
  • Building an empty Android project on the same version of Unity with split binary and app bundle, minification (all of the same app settings) does NOT fail, but is tricky to say it’s project specific because the Unity editor/player has conditional logic based on the size of the assets at play that determines how it uses PAD at build and runtime. Attempting to beef up the size of the project via a ton of Resources folder assets and main executable linked assets so far hasn’t been successful in reproducing this error.
  • I’m about to start my third option at troubleshooting this to see if it’s a plugin or android config specific issue in conjunction with this bug that causes the issue by iteratively removing Android dependencies, commenting or removing that functionality from the app, and verifying the bug still occurs until only native Unity android usage is left. I’ll report back on how successful or not this is.
1 Like

We ended up resolving this on one of the first plugins we removed. Though we don’t have a custom gradle file, we do have a post-build processor we needed to create to fix a duplicate AndroidX/Android Support compile issue.

The original output snippet for the gradle file looked like this:

Before

configurations.implementation
{
    exclude(group : ""com.android.support"")
    exclude(group : ""com.google.android.gms"")
}

After we modified our build processor to not exclude the com.android.gms group we were able to still retain our plugin and avoid this crash issue on startup.

After

configurations.implementation
{
    exclude(group : ""com.android.support"")
}

I am not expert, but what I have found is that downgrading from Google PAD 1.8.0 to 1.7.0 works in my case.