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

Fix avartarUrl NullReferenceException #3287

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 118 additions & 134 deletions Assets/Plugins/Android/GooglePlayGamesManifest.androidlib.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -13,10 +13,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#if UNITY_ANDROID
namespace GooglePlayGames
{

namespace GooglePlayGames {
///
/// This file is automatically generated DO NOT EDIT!
///
@@ -30,43 +29,43 @@ namespace GooglePlayGames
/// by checking whether it still retains its initial value - we prevent the constants from being
/// replaced in the aforementioned search/replace by stripping off the leading and trailing "__".
/// </summary>
public static class GameInfo
{
public static class GameInfo {

private const string UnescapedApplicationId = "APP_ID";
private const string UnescapedIosClientId = "IOS_CLIENTID";
private const string UnescapedWebClientId = "WEB_CLIENTID";
private const string UnescapedNearbyServiceId = "NEARBY_SERVICE_ID";

public const string ApplicationId = "__APP_ID__"; // Filled in automatically
public const string WebClientId = "__WEB_CLIENTID__"; // Filled in automatically
public const string NearbyConnectionServiceId = "__NEARBY_SERVICE_ID__";
public const string ApplicationId = ""; // Filled in automatically
public const string IosClientId = "__IOS_CLIENTID__"; // Filled in automatically
public const string WebClientId = ""; // Filled in automatically
public const string NearbyConnectionServiceId = "";

public static bool ApplicationIdInitialized() {
return !string.IsNullOrEmpty(ApplicationId) && !ApplicationId.Equals(ToEscapedToken(UnescapedApplicationId));
}

public static bool ApplicationIdInitialized()
{
return !string.IsNullOrEmpty(ApplicationId) &&
!ApplicationId.Equals(ToEscapedToken(UnescapedApplicationId));
public static bool IosClientIdInitialized() {
return !string.IsNullOrEmpty(IosClientId) && !IosClientId.Equals(ToEscapedToken(UnescapedIosClientId));
}

public static bool WebClientIdInitialized()
{
public static bool WebClientIdInitialized() {
return !string.IsNullOrEmpty(WebClientId) && !WebClientId.Equals(ToEscapedToken(UnescapedWebClientId));
}

public static bool NearbyConnectionsInitialized()
{
public static bool NearbyConnectionsInitialized() {
return !string.IsNullOrEmpty(NearbyConnectionServiceId) &&
!NearbyConnectionServiceId.Equals(ToEscapedToken(UnescapedNearbyServiceId));
!NearbyConnectionServiceId.Equals(ToEscapedToken(UnescapedNearbyServiceId));
}

/// <summary>
/// Returns an escaped token (i.e. one flanked with "__") for the passed token
/// </summary>
/// <returns>The escaped token.</returns>
/// <param name="token">The Token</param>
private static string ToEscapedToken(string token)
{
private static string ToEscapedToken(string token) {
return string.Format("__{0}__", token);
}
}
}
#endif //UNITY_ANDROID
#endif
Original file line number Diff line number Diff line change
@@ -207,7 +207,7 @@ public override string ToString()
private void setAvatarUrl(string avatarUrl)
{
mAvatarUrl = avatarUrl;
if (!avatarUrl.StartsWith("https") && avatarUrl.StartsWith("http"))
if (!string.IsNullOrEmpty(avatarUrl) && !avatarUrl.StartsWith("https") && avatarUrl.StartsWith("http"))
{
mAvatarUrl = avatarUrl.Insert(4, "s");
}
Original file line number Diff line number Diff line change
@@ -85,6 +85,10 @@ internal static Player ToPlayer(AndroidJavaObject player)
string displayName = player.Call<String>("getDisplayName");
string playerId = player.Call<String>("getPlayerId");
string avatarUrl = player.Call<String>("getIconImageUrl");
if (string.IsNullOrEmpty(avatarUrl))
{
avatarUrl = player.Call<String>("getHiResImageUrl");
}
return new Player(displayName, playerId, avatarUrl);
}

@@ -96,6 +100,10 @@ internal static PlayerProfile ToPlayerProfile(AndroidJavaObject player) {
string displayName = player.Call<String>("getDisplayName");
string playerId = player.Call<String>("getPlayerId");
string avatarUrl = player.Call<String>("getIconImageUrl");
if (string.IsNullOrEmpty(avatarUrl))
{
avatarUrl = player.Call<String>("getHiResImageUrl");
}
bool isFriend =
player.Call<AndroidJavaObject>("getRelationshipInfo").Call<int>("getFriendStatus") ==
4 /* PlayerFriendStatus.Friend*/;
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.
6 changes: 3 additions & 3 deletions SupportFiles/Public/PlayGamesPluginSupport/build.gradle
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

@@ -96,6 +96,6 @@ uploadArchives {
}

dependencies {
implementation 'com.google.android.gms:play-services-games-v2:17.0.0'
implementation 'com.google.android.gms:play-services-nearby:18.5.0'
implementation 'com.google.android.gms:play-services-games-v2:19.0.0'
implementation 'com.google.android.gms:play-services-nearby:19.1.0'
}
Loading