playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.43k stars 952 forks source link

java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames #3154

Open stesproject opened 2 years ago

stesproject commented 2 years ago

I configured everything in the right way, it's been days I am following the documentations, looking for answers and trying with different solutions building each time a new app. Even if I'm pretty sure everything is fine, I still have one last issue before making this plugin working. I can't believe how difficult it is. To summarize:

But nothing helped. As soon as I try to call PlayGamesPlatform methods from my app the error java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames occurs. Is it a bug? What else can I try? I really don't know what else I can do. Thank you for the help.

userqt commented 2 years ago

Hi,

I am having exactly the same error using exactly the same versions of unity and the plugin.

ClassNotFoundException: com.google.android.gms.games.PlayGames

I cannot express what hoops I had to jump through with so many issues along the way just to end up here. It's been weeks of googleing and this whole thing is so fragile, I wonder if it would even work an year from now.

How to resolve this issue?

KyrXtz commented 2 years ago

Make sure you have checked the "Custom proguard txt" option in player settings, and that the txt file is located in Assets/Plugins/Android/proguard-user.txt The contents of the file are mentioned here https://github.com/playgameservices/play-games-plugin-for-unity/issues/2796#issuecomment-1087550133 Also you must force resolve as mentioned here https://github.com/playgameservices/play-games-plugin-for-unity/issues/2796#issuecomment-879303964 If that doesnt work i would try manually deleteing all the .com.goole jar files from the Assets/Plugins/Android/ folder, and then trying to force resolve again.

userqt commented 2 years ago

Hi,

thank you for the quick reply. I am not sure if the proguard custom file even matters, because I tried having it enabled and disabled, force resolving too and it did not help.

What helped however, was to disable the Release checkbox and just leave the Debug one checked. Now I can authenticate. It doesn't show the native pop up, but I can see it in the logs, that it is there. The info I got was from here: https://forum.unity.com/threads/google-play-services-only-work-in-development-builds.1086623/

My credentials and key all use the official release keystore and I was expecting this to work even after minification is Release. I wonder now if the Release one would even work. Here is what I suspect: the Release minification strips the PlayGames code from the final build.

Regarding the native authentication not showing, I see this ticket: https://github.com/playgameservices/play-games-plugin-for-unity/issues/3130

Kind of not clear if this is already resolved but the code need to be released at some point. Idk.

kustomphaq commented 2 years ago

Hi,

thank you for the quick reply. I am not sure if the proguard custom file even matters, because I tried having it enabled and disabled, force resolving too and it did not help.

What helped however, was to disable the Release checkbox and just leave the Debug one checked. Now I can authenticate. It doesn't show the native pop up, but I can see it in the logs, that it is there. The info I got was from here: https://forum.unity.com/threads/google-play-services-only-work-in-development-builds.1086623/

My credentials and key all use the official release keystore and I was expecting this to work even after minification is Release. I wonder now if the Release one would even work. Here is what I suspect: the Release minification strips the PlayGames code from the final build.

Regarding the native authentication not showing, I see this ticket: #3130

Kind of not clear if this is already resolved but the code need to be released at some point. Idk.

I have the same issue like you, Unity version, Firebase and same error. I will try to mark as debug to see if I can authenticate. Do you have progressed about it lately? Cheers, Ruben

userqt commented 2 years ago

Yeah I have it working only when unchecked the Release checkbox (as mentioned in my comment). All it needs is to make it get download the plugin and build it with the app.

jvrieling commented 2 years ago

Unfortunately checking or unchecking the release checkbox and such did not fix it for me. It turns out it was an issue with my GooglePlayGamesPluginDependencies.xml causing my ExternalDependencyManager to fail resolution.

This answer fixed the issue for me!

https://github.com/playgameservices/play-games-plugin-for-unity/issues/2796#issuecomment-1166347984

kustomphaq commented 2 years ago

Unfortunately checking or unchecking the release checkbox and such did not fix it for me. It turns out it was an issue with my GooglePlayGamesPluginDependencies.xml causing my ExternalDependencyManager to fail resolution.

This answer fixed the issue for me! ##2796 (comment)

gonna try it tomorrow, it is very frustrating to see lot of route errors in this plugin, not only in this version :(

somebody knows something about Unity only supports until 10.14 version of plugin?

kustomphaq commented 2 years ago

Just to clarify about proguard setup. Is it only necessary in order to keep apk file size small right? sometimes looks on this answers that it is mandatory to solve our Play Games Services stuff.

jvrieling commented 2 years ago

I don't know to be honest. I figured it's to both keep file size down and keep your code better hidden from decompiling / cheat software. But I'm really not sure.

JinT-Hwang commented 1 year ago

Hi, I found a solution. First, in the publishing settings, check "custom proguard file". Then, find and open the proguard-user.txt file and write the following line of code to the first line.

-keep class com.google.android.gms.games.PlayGames { *; }

Then copy the contents of "Assets\GooglePlayGames\com.google.play.games\Proguard\games.txt" below the line above. Then pack the game and you're done.

If the above is packaged, the game running process reports an error: "requires the Google Play Store, but it is missing." It is for this reason: https://developer.android.google.cn/games/playgames/faq#package_visibility You also need to check "custom main manifest", then open the custom file. Between the two "manifests", insert the following code.

<queries>
    <package android:name="com.google.android.gms" />
    <package android:name="com.android.vending" />
    <package android:name="com.google.android.play.games" />
</queries>

According to the document, after Android 11, if you need to access other applications, you need to declare it first. Then I checked the package names of Google Game Services, Google Store, and Google Play on the phone. Then fill it in, because I'm not sure which one is useful and which one doesn't, the safest is to write them all.

For me this works. I've been stuck in this place for three days...

This is my file content. The AndroidManifest.xml file may be different for everyone, just insert two "queries"..

proguard-user.txt↓↓↓↓↓↓

-keep class com.google.android.gms.games.PlayGames { *; } -keep class com.google.android.gms.games.leaderboard. { *; } -keep class com.google.android.gms.games.snapshot.* { ; } -keep class com.google.android.gms.games.achievement. { *; } -keep class com.google.android.gms.games.event. { *; } -keep class com.google.android.gms.games.stats. { ; } -keep class com.google.android.gms.games. { ; } -keep class com.google.android.gms.common.api.ResultCallback { ; } -keep class com.google.android.gms.signin. { *; } -keep class com.google.android.gms.dynamic. { *; } -keep class com.google.android.gms.dynamite. { *; } -keep class com.google.android.gms.tasks.* { ; } -keep class com.google.android.gms.security. { *; } -keep class com.google.android.gms.base. { *; } -keep class com.google.android.gms.actions.* { ; } -keep class com.google.games.bridge. { ; } -keep class com.google.android.gms.common.ConnectionResult { ; } -keep class com.google.android.gms.common.GooglePlayServicesUtil { *; } -keep class com.google.android.gms.common.api. { ; } -keep class com.google.android.gms.common.data.DataBufferUtils { ; } -keep class com.google.android.gms.nearby. { *; }

AndroidManifest.xml↓↓↓↓↓↓

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
              android:theme="@style/UnityThemeSelector">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
  </application>
  <queries>
    <package android:name="com.google.android.gms" />
    <package android:name="com.android.vending" />
    <package android:name="com.google.android.play.games" />
  </queries>
</manifest>
restush commented 1 year ago

everything above is not working, but then I update External Dependency to newest version, then it works.

Tripletri commented 11 months ago

I used the PlayServicesResolver and I had this issue. Installed External Dependency Manager plugin, force resolved dependencies and the issue gone.

Unity: v2022.1.24f1 GPGS: v0.11.1 External Dependency Manager: v1.2.176

Build setting Mono .NET Standard 2.1 Stripping Disabled Publishing settings image

proguard-user.txt -keep class com.google.android.gms.games.PlayGames { *; } -keep class com.google.android.gms.games.leaderboard.** { *; } -keep class com.google.android.gms.games.snapshot.** { *; } -keep class com.google.android.gms.games.achievement.** { *; } -keep class com.google.android.gms.games.event.** { *; } -keep class com.google.android.gms.games.stats.** { *; } -keep class com.google.android.gms.games.* { *; } -keep class com.google.android.gms.common.api.ResultCallback { *; } -keep class com.google.android.gms.signin.** { *; } -keep class com.google.android.gms.dynamic.** { *; } -keep class com.google.android.gms.dynamite.** { *; } -keep class com.google.android.gms.tasks.** { *; } -keep class com.google.android.gms.security.** { *; } -keep class com.google.android.gms.base.** { *; } -keep class com.google.android.gms.actions.** { *; } -keep class com.google.games.bridge.** { *; } -keep class com.google.android.gms.common.ConnectionResult { *; } -keep class com.google.android.gms.common.GooglePlayServicesUtil { *; } -keep class com.google.android.gms.common.api.** { *; } -keep class com.google.android.gms.common.data.DataBufferUtils { *; } -keep class com.google.android.gms.nearby.** { *; }

P.S I will try with other build settings and update comment

rafalkasa commented 10 months ago

Upgrade External Dependency Manager was issue for me https://github.com/googlesamples/unity-jar-resolver/releases/tag/v1.2.176

Unity: v2022.3.7f1 GPGS: v0.11.1 External Dependency Manager: v1.2.176

proguard-user.txt:

-keep class com.google.unity.** { 
    *; 
} 
-keep class com.google.android.gms.** { 
    public *;  
}
-keep public class com.google.android.gms.games.** { 
    public *; 
}
-keep public class com.google.games.bridge.** { 
    public *; 
}
-keepattributes *Annotation 
-dontobfuscate
MarvinJesus commented 10 months ago

Hello everyone, my problem was the same and it was solved when I forced to resolve the dependencies for Android, it also worked when I only resolved dependencies. I did it like this: Assets > ExternalDependencyManager > AndroidResolver > Force Resolve or Assets > ExternalDependencyManager > AndroidResolver > Resolve.

Battle4King commented 9 months ago

Just Update progard.txt file under project setting below

-keep class com.google.android.gms.games.PlayGames { *; } -keep class com.google.android.gms.games.leaderboard. { *; } -keep class com.google.android.gms.games.snapshot.* { ; } -keep class com.google.android.gms.games.achievement. { *; } -keep class com.google.android.gms.games.event. { *; } -keep class com.google.android.gms.games.stats.* { ; } -keep class com.google.android.gms.games.video. { ; } -keep class com.google.android.gms.games. { ; } -keep class com.google.android.gms.common.api.ResultCallback { ; } -keep class com.google.android.gms.signin. { *; } -keep class com.google.android.gms.dynamic.* { ; } -keep class com.google.android.gms.dynamite. { *; } -keep class com.google.android.gms.tasks. { *; } -keep class com.google.android.gms.security.* { ; } -keep class com.google.android.gms.base. { *; } -keep class com.google.android.gms.actions. { *; } -keep class com.google.games.bridge.* { ; } -keep class com.google.android.gms.common.ConnectionResult { ; } -keep class com.google.android.gms.common.GooglePlayServicesUtil { ; } -keep class com.google.android.gms.common.api. { ; } -keep class com.google.android.gms.common.data.DataBufferUtils { ; } -keep class com.google.android.gms.games.quest.* { ; } -keep class com.google.android.gms.nearby.* { ; }

this will solve this error for me

but then i can't show leaderboardUI show error for this you have to add below line after authentication PlayGamesPlatform.Activate();

this will show leaderboard pop up also when hit leaderboard show button

ScottyGav commented 9 months ago

Another variation:

This was my problem

With the solution described by suchiz, ... ignoring that they are still using Packages in the path.

I've only updated the one file, GooglePlayGamesPluginDependencies.xml with:

Assets/GooglePlayGames/com.google.play.games/Editor/m2repository

Note that the Local Maven Repo Directory button is within the Android Resolver Settings.

image

Unity 2022.3.2 google-signin-plugin-1.0.4.unitypackage GooglePlayGamesPlugin-0.11.01.unitypackage external-dependency-manager-1.2.176.unitypackage

EDIT #1:

no progard, and debug minify authenticating with:

PlayGamesPlatform.Instance.Authenticate() Social.localUser.Authenticate()

image

EDIT #2:

I had regression while making other edits, so I thought I'd add some detail to help debug.

If Assets\GeneratedLocalRepo\GooglePlayGames does not exist, GooglePlayGamesPluginDependencies.xml may be in error. Once updated, 'Force Resolve' will build this directory.

image

I did have the problem that something in \MyProject\Library was continually rewriting the .XML with the default/erroneous config. I'll look closer next time but I deleted the Library folder altogether without trouble (I needed to reselect Android as a platform but that was all that was lost.)

Battle4King commented 9 months ago

I think you have to change your custom progard file and also minify on when build

On Thu, 28 Sept, 2023, 4:44 pm ScottyGav, @.***> wrote:

Another variation:

This was my problem https://github.com/google/play-unity-plugins#play-core-library-conflicts

With the solution described https://github.com/googlesamples/unity-jar-resolver/issues/535 by suchiz, ... ignoring that they are still using Packages in the path.

I've only updated the one file, GooglePlayGamesPluginDependencies.xml with:

Assets/GooglePlayGames/com.google.play.games/Editor/m2repository

Note that the Local Maven Repo Directory button is within the Android Resolver Settings. [image: image] https://user-images.githubusercontent.com/7378655/271262404-cf4faf51-bc5e-4257-93a3-efb7726e3fbf.png

Unity 2022.3.2 google-signin-plugin-1.0.4.unitypackage GooglePlayGamesPlugin-0.11.01.unitypackage external-dependency-manager-1.2.176.unitypackage

— Reply to this email directly, view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/3154#issuecomment-1738948581, or unsubscribe https://github.com/notifications/unsubscribe-auth/BA4A3NZLVC6FWQGN6OFI563X4VLZ3ANCNFSM5VZGGQDQ . You are receiving this because you commented.Message ID: <playgameservices/play-games-plugin-for-unity/issues/3154/1738948581@ github.com>

ScottyGav commented 9 months ago

it works without it but will look at minify. I'll update if it breaks.

cristianjuarezz commented 9 months ago

Im having no luck, this happens only if I have both this plugin and the AdMob one at the same time, otherwise they work fine individually

Battle4King commented 9 months ago

Update your resolve

Then try force resolve successfully

Also you have to update manually your proguard.txt file

Maybe it will work

On Mon, 2 Oct, 2023, 9:00 am Cristian Juarez, @.***> wrote:

Im having no luck, this happens only if I have both this plugin and the AdMob one at the same time, otherwise they work fine individually

— Reply to this email directly, view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/3154#issuecomment-1742354852, or unsubscribe https://github.com/notifications/unsubscribe-auth/BA4A3N3DKC2TTWM53OLL3ITX5IYOHANCNFSM5VZGGQDQ . You are receiving this because you commented.Message ID: <playgameservices/play-games-plugin-for-unity/issues/3154/1742354852@ github.com>

PQPMath3ws commented 9 months ago

everything above is not working, but then I update External Dependency to newest version, then it works.

thank you, @restush - really works this!

rami-al-rahim commented 6 months ago

Hi I tried to change this line of code in GooglePlayGamesPluginDependencies.xml form this <repository>Packages/com.google.play.games/Editor/m2repository</repository> to this <repository>Assets/GooglePlayGames/com.google.play.games/Editor/m2repository</repository> I hope this help you

DarylVassallo commented 4 months ago

Hello everyone, my problem was the same and it was solved when I forced to resolve the dependencies for Android, it also worked when I only resolved dependencies. I did it like this: Assets > ExternalDependencyManager > AndroidResolver > Force Resolve or Assets > ExternalDependencyManager > AndroidResolver > Resolve.

I have nothing to add. Just wanted to say that this worked for me, and was a huge relief. Have been trying to get this working for ages. Thank you so much!!!

segunabiodun commented 3 months ago

Upgrade External Dependency Manager was issue for me https://github.com/googlesamples/unity-jar-resolver/releases/tag/v1.2.176

Unity: v2022.3.7f1 GPGS: v0.11.1 External Dependency Manager: v1.2.176

proguard-user.txt:

-keep class com.google.unity.** { 
  *; 
} 
-keep class com.google.android.gms.** { 
  public *;  
}
-keep public class com.google.android.gms.games.** { 
  public *; 
}
-keep public class com.google.games.bridge.** { 
  public *; 
}
-keepattributes *Annotation 
-dontobfuscate

This from @rafalkasa is what solves it for me. Thanks!