playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.45k stars 961 forks source link

Build doesn't include classes of 'com.google.games:gpgs-plugin-support:0.9.64' #2605

Open Danand opened 5 years ago

Danand commented 5 years ago

Well-known exception occured on every authentification attempt:

UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment

Android Studio also founds unresolved class error at: <activity android:name="com.google.games.bridge.NativeBridgeActivity"

Result build doesn't contain com.google.games.bridge classes in any .dex file.

I've found the only way to fix this: Rename all occurrences of .srcaar to .aar in Assets/GooglePlayGames/Editor/m2repository/com/google/games/gpgs-plugin-support/

  1. Rename files.
  2. Fix <packaging>aar</packaging> in .pom files.

After this steps classes was included in .dex and everything works fine.

Play Games Plugin version: 0.9.64 Play Services Resolver version: 1.2.117 (updated because latest fixes may help)

So why .srcaar extension doesn't work and is there really need for it?

legas1 commented 5 years ago

.srcaar is here to intentionally be ignored by Unity. Resolver takes (resolve) this file and place it properly in Plugins/Android with proper .aar extension.

Have you tried force resolve option in Resolver's menu? By mentioning Android Studio here, are you building exported project?

Danand commented 5 years ago

Have you tried force resolve option in Resolver's menu?

Yes. Resolver removed existing .aar file so I considered it was legacy or something.

By mentioning Android Studio here, are you building exported project?

Yes. I use it for reviewing dependencies,

OK. Thanks for advice! I'll try to delete and import plugin & resolver package, and resolve dependencies again.

Danand commented 5 years ago

So resolver didn't added .aar file to Plugins/Android in my case (using custom Gradle template and export to Android Studio). Resolver adds dependency implementation 'com.google.games:gpgs-plugin-support:0.9.64' and path to local Maven repository:

maven {
    url "file:///C:/project/Assets/GooglePlayGames/Editor/m2repository" // Assets/GooglePlayGames/Editor/GooglePlayGamesPluginDependencies.xml:11
}

I'm cool with that behaviour, I liked referencing to repository instead of copying all libraries to Plugins/Android, but it looks like .aar was not placed when using local repository with .srcaar in that case.

legas1 commented 5 years ago

Sorry for mystification, you were right, I was still using older version of Jar Resolver, by 1.2.105 better integration with Gradle was added if you use custom Gradle template. Some details are noted here: https://github.com/googlesamples/unity-jar-resolver/issues/233#issuecomment-501460820, so aars should be deleted from Plugins/Android. Local m2 repos resolve aars next to srcaars.