Google Play Services (Unity)无法在设备上运行


using System;
using System.Collections;
using System.Collections.Generic;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;
using UnityEngine.SocialPlatforms;
using UnityEngine.EventSystems;
public class GooglePlayServicesController : MonoBehaviour
{
public static GooglePlayServicesController googlePlayServicesController;
public static bool hasInterent = false;
public static PlayGamesPlatform platform;
void Start()
{
if (googlePlayServicesController == null)
{
googlePlayServicesController = this;
}
DontDestroyOnLoad(this);
if (Application.internetReachability != NetworkReachability.NotReachable)
{
hasInterent = true;
SignInToGooglePlayServices();
}
else
{
hasInterent = false;
}

}
public void AddScoreToLeaderBoard()
{
if (hasInterent)
{
PlayerController.playerController.player.LoadPlayer();
if (Social.localUser.authenticated)
{
Social.ReportScore(PlayerController.playerController.player.statMoles, "YOUR ID", success => { });
}
else
{
SignInToGooglePlayServices();
}
}
}
public void ShowLeaderboard()
{
EventSystem.current.SetSelectedGameObject(null);
if (hasInterent)
{
if (Social.localUser.authenticated)
{
Social.ShowLeaderboardUI();
}
else
{
SignInToGooglePlayServices();
}
}
}
public void SignInToGooglePlayServices()
{
if (hasInterent)
{
if (platform == null)
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = false;
platform = PlayGamesPlatform.Activate();
}
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, (result) => { });
Social.Active.localUser.Authenticate(success =>
{
if (success)
{
Debug.Log("Logged in successfully");
}
else
{
Debug.Log("Login Failed");
}
});
}
}
}

所以我有一个项目工作良好的代码,我已经发布,但这个项目一直有点棘手。我无法让GPGS在设备上工作:

  1. 它在playstore的内部和alpha测试

  2. 我在proguard中有以下内容

    -keepnames class com.google.android.gms.** {*;}
    #GameService Rules
    -keep class com.google.android.gms.** { *; }
    -keep class com.google.games.bridge.** { *; }
    -keep class com.google.unity.** { *; }
    #Don't obfuscate. We only need dead code striping.
    -dontobfuscate   
    

我猜这和这个有关系

AndroidJavaException:java.lang.ClassNotFoundException:com.google.android.gms.games.Games

,但我仍然得到这个错误在LogCat:

0001/01/01 00:00:00.000 -1 -1 Info  --------- beginning of main
2022/05/10 21:23:53.109 6445 6445 Error ouse.HoleyMole Not starting debugger since process cannot load the jdwp agent.
2022/05/10 21:23:53.117 6445 6445 Debug CompatibilityChangeReporter Compat change id reported: 171979766; UID 10152; state: DISABLED
2022/05/10 21:23:53.122 6445 6445 Warn ouse.HoleyMole Entry not found
2022/05/10 21:23:53.123 6445 6445 Warn ouse.HoleyMole JIT profile information will not be recorded: profile file does not exist.
2022/05/10 21:23:53.125 6445 6445 Verbose GraphicsEnvironment ANGLE Developer option for 'com.DavincosWarehouse.HoleyMoley' set to: 'default'
2022/05/10 21:23:53.125 6445 6445 Verbose GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
2022/05/10 21:23:53.126 6445 6445 Debug NetworkSecurityConfig No Network Security Config specified, using platform default
2022/05/10 21:23:53.126 6445 6445 Debug NetworkSecurityConfig No Network Security Config specified, using platform default
2022/05/10 21:23:53.158 6445 6445 Info IL2CPP JNI_OnLoad
2022/05/10 21:23:53.191 6445 6445 Info Gralloc4 mapper 4.x is not supported
2022/05/10 21:23:53.192 6445 6445 Debug HostConnection createUnique: call
2022/05/10 21:23:53.194 6445 6445 Debug HostConnection HostConnection::get() New Host Connection established 0xb4000078b23a9ed0, tid 6445
2022/05/10 21:23:53.194 6445 6445 Debug goldfish-address-space allocate: Ask for block of size 0x100
2022/05/10 21:23:53.194 6445 6445 Debug goldfish-address-space allocate: ioctl allocate returned offset 0x1efff8000 size 0x8000
2022/05/10 21:23:53.195 6445 6445 Warn Gralloc4 allocator 4.x is not supported
2022/05/10 21:23:53.220 6445 6445 Debug HostConnection HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
2022/05/10 21:23:53.239 6445 6463 Info Unity MemoryManager: Using 'Dynamic Heap' Allocator.
2022/05/10 21:23:53.255 6445 6463 Info Unity SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 4, Memory = 1966mb
2022/05/10 21:23:53.255 6445 6463 Info Unity SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf), 0 little (mask: 0x0)
2022/05/10 21:23:53.255 6445 6463 Info Unity ApplicationInfo com.DavincosWarehouse.HoleyMoley version 1.0.6
2022/05/10 21:23:53.255 6445 6463 Info Unity Built from '2021.3/staging' branch, Version '2021.3.2f1 (d6360bedb9a0)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a', Stripping 'Enabled'
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.294 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.295 6445 6463 Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
2022/05/10 21:23:53.298 6445 6463 Info Unity Company Name: Davinco's Warehouse
2022/05/10 21:23:53.298 6445 6463 Info Unity Product Name: Holey Moley
2022/05/10 21:23:53.306 6445 6463 Debug libEGL loaded /vendor/lib64/egl/libEGL_emulation.so
2022/05/10 21:23:53.307 6445 6463 Debug libEGL loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
2022/05/10 21:23:53.308 6445 6463 Debug libEGL loaded /vendor/lib64/egl/libGLESv2_emulation.so
2022/05/10 21:23:53.315 6445 6463 Debug HostConnection createUnique: call
2022/05/10 21:23:53.315 6445 6463 Debug HostConnection HostConnection::get() New Host Connection established 0xb4000078b23a8850, tid 6463
2022/05/10 21:23:53.317 6445 6463 Debug HostConnection HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation eglCreateContext: EGL_BAD_CONFIG: no ES 3.2 support
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation tid 6463: eglCreateContext(1849): error 0x3005 (EGL_BAD_CONFIG)
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation eglCreateContext: EGL_BAD_CONFIG: no ES 3.1 support
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation tid 6463: eglCreateContext(1843): error 0x3005 (EGL_BAD_CONFIG)
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation [getAttribValue] Bad attribute idx
2022/05/10 21:23:53.320 6445 6463 Debug EGL_emulation eglGetConfigAttrib: bad attrib 0x1
2022/05/10 21:23:53.320 6445 6463 Error EGL_emulation tid 6463: eglGetConfigAttrib(1292): error 0x3004 (EGL_BAD_ATTRIBUTE)
2022/05/10 21:23:53.321 6445 6463 Debug EGL_emulation eglCreateContext: 0xb4000078b23a9f90: maj 3 min 0 rcv 3
2022/05/10 21:23:53.322 6445 6463 Debug EGL_emulation eglCreateContext: 0xb4000078b23a9f90: maj 3 min 0 rcv 3
2022/05/10 21:23:53.323 6445 6463 Debug EGL_emulation eglCreateContext: 0xb4000078b23a9f90: maj 3 min 0 rcv 3
2022/05/10 21:23:53.323 6445 6463 Debug EGL_emulation eglMakeCurrent: 0xb4000078b23a9f90: ver 3 0 (tinfo 0x7acbe70080) (first time)
2022/05/10 21:23:53.325 6445 6463 Debug Unity  GL_EXT_debug_marker GL_EXT_robustness GL_OES_EGL_sync GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_npot GL_OES_rgb8_rgba8 GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888 ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulka
2022/05/10 21:23:53.325 6445 6463 Debug Unity n_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
2022/05/10 21:23:53.326 6445 6494 Debug HostConnection createUnique: call
2022/05/10 21:23:53.327 6445 6494 Debug HostConnection HostConnection::get() New Host Connection established 0xb4000078b23a9810, tid 6494
2022/05/10 21:23:53.328 6445 6494 Debug HostConnection HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
2022/05/10 21:23:53.328 6445 6494 Debug EGL_emulation eglMakeCurrent: 0xb4000078b23a9f90: ver 3 0 (tinfo 0x7acbe70100) (first time)
2022/05/10 21:23:53.355 6445 6496 Warn AudioTrack Use of stream types is deprecated for operations other than volume control
2022/05/10 21:23:53.355 6445 6496 Warn AudioTrack See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case
2022/05/10 21:23:53.376 6445 6463 Verbose MediaRouter Selecting route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=System types=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO  groupable=false }, supportedTypes=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO , presentationDisplay=null }
2022/05/10 21:23:53.377 6445 6463 Info MediaRouter Skip setBluetoothA2dpOn(): types=8388615, isPlaybackActive()=true, BT route=null
2022/05/10 21:23:54.487 6445 6494 Debug EGL_emulation app_time_stats: avg=1.77ms min=1.21ms max=6.09ms count=61
2022/05/10 21:23:55.439 6445 6463 Debug CompatibilityChangeReporter Compat change id reported: 147600208; UID 10152; state: ENABLED
2022/05/10 21:23:55.474 6445 6463 Info IL2CPP Locale en-US
2022/05/10 21:23:55.501 6445 6463 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/05/10 21:23:55.501 6445 6463 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/05/10 21:23:55.501 6445 6463 Error Unity   at java.lang.Class.classForName(Native Method)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at java.lang.Class.forName(Class.java:454)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at android.os.Handler.dispatchMessage(Handler.java:102)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at android.os.Looper.loopOnce(Looper.java:201)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at android.os.Looper.loop(Looper.java:288)
2022/05/10 21:23:55.501 6445 6463 Error Unity   at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2022/05/10 21:23:55.501 6445 6463 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/05/10 21:23:55.501 6445 6463 Error Unity   ... 9 more
2022/05/10 21:23:55.501 6445 6463 Error Unity   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
2022/05/10 21:23:55.501 6445 6463 Error Unity   at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 
2022/05/10 21:23:55.501 6445 6463 Error Unity   at UnityEngine.AndroidJavaClass._AndroidJavaClass (Sys
2022/05/10 21:23:55.542 6445 6494 Debug EGL_emulation app_time_stats: avg=3.84ms min=1.25ms max=103.36ms count=57
2022/05/10 21:23:56.567 6445 6494 Debug EGL_emulation app_time_stats: avg=32.75ms min=1.52ms max=39.50ms count=31
2022/05/10 21:23:57.589 6445 6494 Debug EGL_emulation app_time_stats: avg=34.08ms min=30.46ms max=37.20ms count=30
2022/05/10 21:23:58.608 6445 6494 Debug EGL_emulation app_time_stats: avg=33.93ms min=29.50ms max=37.12ms count=30
2022/05/10 21:23:59.610 6445 6494 Debug EGL_emulation app_time_stats: avg=34.56ms min=26.33ms max=39.56ms count=29
2022/05/10 21:24:00.629 6445 6494 Debug EGL_emulation app_time_stats: avg=33.95ms min=31.39ms max=36.52ms count=30
2022/05/10 21:24:01.662 6445 6494 Debug EGL_emulation app_time_stats: avg=34.41ms min=30.46ms max=38.45ms count=30

发现原因似乎GPGS在其设置过程中非常非常具体。

仅仅因为你制作了所有的排行榜等等,你就需要发布它们……这是在测试人员仍然可以使用之前认为的

所以一定要

  1. 在Unity中添加客户端ID
  2. 添加混淆器
  3. 在GoogelPlay控制台发布和发布排行榜

然后你可以使用内部测试和工作就像一个魅力。

很抱歉我的愚蠢,但可能会在未来帮助某人解决设置GPGS的众多问题之一

相关内容

  • 没有找到相关文章

最新更新