playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.44k stars 959 forks source link

Lokhttp3/OkHttpClient exception crashes app #3014

Closed DawidB closed 3 years ago

DawidB commented 3 years ago

I have added GooglePlayGames plugin v10.12 to my Unity (2019.4.20f1) game and I managed to successfully build it for Android (API 29) and deploy it. The game starts and player is able to use Google login with no issues. However when scene is switched, the game crashes with an error: _FATAL EXCEPTION: Thread-22 Process: com.appid, PID: 32371 java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient$Builder; at com.microsoft.xplatcppsdk_internal.HttpRequest.(HttpRequest.java:24) Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient$Builder" on path: DexPathList[[zip file "/data/app/com.appid-HtfeIsrd6KdOTXdmiaMsrg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appid-HtfeIsrd6KdOTXdmiaMsrg==/lib/arm, /data/app/com.appid-HtfeIsrd6KdOTXdmiaMsrg==/base.apk!/lib/armeabi-v7a, /system/lib, /system/product/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.microsoft.xplatcppsdkinternal.HttpRequest.(HttpRequest.java:24)

As I suspect it may have something to do with JAR resolver, but I have no clue how to resolve it.

DawidB commented 3 years ago

Found out the root cause - Playfab SDK was causing it.

It seems that enabling Custom Main Gradle Template with default template autogenerated by Unity fixes the problem, as it already includes missing lib: implementation 'com.squareup.okhttp3:okhttp:3.10.0'

To enable custom gradle template, open Project Settings, select Player tab and then navigate to Publish Settings section. image