Skip to content

Commit

Permalink
Merge pull request #2768 from mukhinid/fix_2018_sdk_path
Browse files Browse the repository at this point in the history
Fixed android sdk path detection in versions older than 2019.x
  • Loading branch information
olehkuznetsov authored Oct 29, 2019
2 parents 4886f01 + 09bdd5e commit 213f680
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions source/PluginDev/Assets/GooglePlayGames/Editor/GPGSUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,13 @@ public static void Alert(string title, string message)
public static string GetAndroidSdkPath()
{
string sdkPath = EditorPrefs.GetString("AndroidSdkRoot");
#if UNITY_2019
// Unity 2019.x added installation of the Android SDK in the AndroidPlayer directory
// so fallback to searching for it there.
if (String.IsNullOrEmpty(sdkPath) || EditorPrefs.GetBool("SdkUseEmbedded"))
if (string.IsNullOrEmpty(sdkPath) || EditorPrefs.GetBool("SdkUseEmbedded"))
{
string androidPlayerDir = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.Android, BuildOptions.None);
if (!String.IsNullOrEmpty(androidPlayerDir))
if (!string.IsNullOrEmpty(androidPlayerDir))
{
string androidPlayerSdkDir = Path.Combine(androidPlayerDir, "SDK");
if (Directory.Exists(androidPlayerSdkDir))
Expand All @@ -459,6 +460,12 @@ public static string GetAndroidSdkPath()
}
}
}
#endif
if (sdkPath != null && (sdkPath.EndsWith("/") || sdkPath.EndsWith("\\")))
{
sdkPath = sdkPath.Substring(0, sdkPath.Length - 1);
}

return sdkPath;
}

Expand Down

0 comments on commit 213f680

Please sign in to comment.