Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stesproject opened this issue May 12, 2022 · 25 comments
Open
Labels

Comments

@stesproject
Copy link

  • Unity version: 2021.3 LTS
  • Google Play Games Plugin for Unity version: 0.11.01

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:

  • My resources are set in the Google Play Games Android configuration
  • I have associated a Client ID (the web client one of type Web application)
  • Project and dependencies resolve successfully
  • I just have GPGS and Firebase plugins installed in the project
  • In Player settings I have checked Minify: Release and Debug (nothing else)
  • Minimum API Level and Target API Level are set to 30 (Android 11.0)
  • Scripting Backend: IL2CPP - Api Compatibility Level: .NET Framework
  • I even tried to paste the suggested content of the proguard-user.txt file as suggested here: Exception class not found com.google.android.gms.games.Games on Authenticate, v0.10.06. #2796

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
Copy link

userqt commented May 18, 2022

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
Copy link

KyrXtz commented May 18, 2022

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 #2796 (comment)
Also you must force resolve as mentioned here #2796 (comment)
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
Copy link

userqt commented May 18, 2022

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.

@kustomphaq
Copy link

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
Copy link

userqt commented Jun 26, 2022

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
Copy link

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)

@kustomphaq
Copy link

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
Copy link

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
Copy link

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
Copy link

JinT-Hwang commented Oct 27, 2022

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
Copy link

restush commented Jul 5, 2023

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

@Tripletri
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

ScottyGav commented Sep 28, 2023

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
Copy link

Battle4King commented Sep 28, 2023 via email

@ScottyGav
Copy link

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

@cristianjuarezz
Copy link

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
Copy link

Battle4King commented Oct 2, 2023 via email

@PQPMath3ws
Copy link

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
Copy link

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
Copy link

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
Copy link

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!

@AlexanderParker
Copy link

I just wanted to chime in and add that I was upgrading from a 2014 build (very ancient) and had these same issues. I've been trying different things for a few weeks in between refactoring the UI.

Everyone who recommended to use the "force resolve external dependencies" has my eternal gratitude!

Seeing that play leaderboard and achievements list working for the first time in years is fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests