안드로이드에서 뒤끝 로그인이 안되는 문제가 있어 글 남겨요
Google Hash Key는 있지만 혹시
Google Hash Key 없이 앱을 실행 할 방법이 없을까요?
Proguard 은 사용하지 않지만 예외 정보를 입력후 다시 해보라는 글이 있어서 해봤습니다
-keep class io.thebackend.unity.** {
*;
}
-keep class io.thebackend.webview.** {
*;
}
위와 같이 설정을 추가해도 로그인이 안돼요
- 뒤끝 SDK 버전 : 5.18.0
- 프로젝트명 : TheHacker
- 스테이터스 코드 : 400
- 에러 코드 :
[Header("로그아웃 버튼추가")]
public Button logoutButton;
public static GoogleLoginManager Instance;
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject); // 씬이 바뀌어도 오브젝트가 파괴되지 않도록 설정
}
// Firebase 인증 관련 객체
FirebaseAuth auth;
FirebaseUser user;
// 사용자 정보 표시용 UI 요소
private string Username, UserEmail, UserId;
//확인용
public TextMeshProUGUI tUsername, tUserEmail, tUserId;
public Image UserProfilePic;
// 프로필 이미지 URL 및 초기화 상태
private string imageUrl;
private bool isGoogleSignInInitialized = false;
/// <summary>
/// 컴포넌트가 시작될 때 Firebase 초기화 및 로그인 시도
/// </summary>
private void Start()
{
logoutButton.onClick.AddListener(Logout);
InitFirebase();
Login();
}
/// <summary>
/// Firebase 인증 객체 초기화
/// </summary>
void InitFirebase()
{
auth = FirebaseAuth.DefaultInstance;
}
/// <summary>
/// Google 계정으로 로그인 시도 및 결과 처리
/// </summary>
private void Login()
{
// 에디터에서만 사용되는 코드 #if
#if UNITY_EDITOR
BackendManager.Instance.OnBackendLogin("mytestusesr05", "mytestusesr05email");
#endif
// 안드로이드에서만 사용되는 코드 #if
#if UNITY_ANDROID
// Google Sign-In 설정 초기화
if (!isGoogleSignInInitialized)
{
GoogleSignIn.Configuration = new GoogleSignInConfiguration
{
RequestIdToken = true,
WebClientId = GoogleAPI,
RequestEmail = true
};
isGoogleSignInInitialized = true;
}
// 매번 Sign-In 시도 시에도 설정 적용
GoogleSignIn.Configuration = new GoogleSignInConfiguration
{
RequestIdToken = true,
WebClientId = GoogleAPI
};
GoogleSignIn.Configuration.RequestEmail = true;
// Google 로그인 비동기 작업 시작
Task<GoogleSignInUser> signIn = GoogleSignIn.DefaultInstance.SignIn();
TaskCompletionSource<FirebaseUser> signInCompleted = new TaskCompletionSource<FirebaseUser>();
signIn.ContinueWith(task =>
{
if (task.IsCanceled)
{
signInCompleted.SetCanceled();
Debug.Log("Cancelled");
print("인증 실패로 프로그램을 종료합니다.");
Application.Quit();
}
else if (task.IsFaulted)
{
signInCompleted.SetException(task.Exception);
Debug.Log("Faulted " + task.Exception);
print("인증 실패로 프로그램을 종료합니다.");
Application.Quit();
}
else
{
// Google 인증 토큰으로 Firebase 인증 시도
Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(((Task<GoogleSignInUser>)task).Result.IdToken, null);
auth.SignInWithCredentialAsync(credential).ContinueWith(authTask =>
{
if (authTask.IsCanceled)
{
signInCompleted.SetCanceled();
// 인증이 취소된 경우 프로그램 종료
print("인증 실패로 프로그램을 종료합니다.");
Application.Quit();
}
else if (authTask.IsFaulted)
{
signInCompleted.SetException(authTask.Exception);
Debug.Log("Faulted In Auth " + task.Exception);
// 인증 실패 program 종료
print("인증 실패로 프로그램을 종료합니다.");
Application.Quit();
}
else
{
// 인증 성공 시 사용자 정보 UI에 표시 및 프로필 이미지 로드
signInCompleted.SetResult(((Task<FirebaseUser>)authTask).Result);
Debug.Log("Success");
user = auth.CurrentUser;
Username = user.DisplayName;
UserEmail = user.Email;
UserId = user.UserId;
// 뒤끝 로그인
BackendManager.Instance.OnBackendLogin(UserId, UserEmail);
tUserEmail.text = UserEmail;
tUsername.text = Username;
tUserId.text = UserId;
print("user HashCode" + user.GetHashCode());
StartCoroutine(LoadImage(CheckImageUrl(user.PhotoUrl.ToString())));
}
});
}
});
#endif
}
/// <summary>
/// 프로필 이미지 URL이 유효한지 확인 후 반환
/// </summary>
private string CheckImageUrl(string url)
{
if (!string.IsNullOrEmpty(url))
{
return url;
}
return imageUrl;
}
/// <summary>
/// 주어진 이미지 URL로부터 이미지를 비동기적으로 로드하여 UI에 표시
/// </summary>
IEnumerator LoadImage(string imageUri)
{
UnityWebRequest www = UnityWebRequestTexture.GetTexture(imageUri);
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.Success)
{
Texture2D texture = DownloadHandlerTexture.GetContent(www);
// 로드된 텍스처를 UI 이미지로 적용
Debug.Log("Image loaded successfully");
UserProfilePic.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0));
}
else
{
Debug.Log("Error loading image: " + www.error);
}
}
private void Logout()
{
// Firebase 로그아웃
auth.SignOut();
// Google 로그아웃
GoogleSignIn.DefaultInstance.SignOut();
Debug.Log("User logged out");
// UI 초기화
tUsername.text = "Not logged in";
tUserEmail.text = "Not logged in";
tUserId.text = "Not logged in";
UserId = string.Empty;
Username = string.Empty;
UserEmail = string.Empty;
UserProfilePic.sprite = null; // 프로필 이미지 초기화
print("로그아웃 하여 프로그램 종료합니다.");
// end
Application.Quit();
}
- 에러 메시지 :
2025-07-22 13:45:06.393 19779 19819 Error Unity Backend Util Android AAR Issue : java.lang.ClassNotFoundException: io.thebackend.unity.Utils.CommonUtil
2025-07-22 13:45:06.393 19779 19819 Error Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
2025-07-22 13:45:06.393 19779 19819 Error Unity BackEnd.Functions.AndroidFunctions:.ctor()
2025-07-22 13:45:06.393 19779 19819 Error Unity System.Reflection.RuntimeConstructorInfo:InternalInvoke(Object, Object[], Boolean)
2025-07-22 13:45:06.393 19779 19819 Error Unity System.Activator:CreateInstance()
2025-07-22 13:45:06.393 19779 19819 Error Unity System.Lazy1:ViaFactory(LazyThreadSafetyMode) 2025-07-22 13:45:06.393 19779 19819 Error Unity System.Lazy
1:ExecutionAndPublication(LazyHelper, Boolean)
2025-07-22 13:45:06.393 19779 19819 Error Unity System.Lazy`1:CreateValue()
2025-07-22 13:45:06.393 19779 19819 Error Unity BackEnd.Backend:avJ7p3rmx(BackendCustomSetting)
2025-07-22 13:45:06.393 19779 19819 Error Unity BackEnd.Backend:Initialize(BackendCustomSetting)
2025-07-22 13:45:06.393 19779 19819 Error Unity BackEnd.Backend:Initialize()
2025-07-22 13:45:06.393 19779 19819 Error Unity BackendManager:Start()
2025-07-22 13:45:06.393 19779 19819 Error Unity
2025-07-22 13:45:09.855 19779 19916 Info Unity 회원가입을 요청합니다.
2025-07-22 13:45:09.855 19779 19916 Info Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
2025-07-22 13:45:09.855 19779 19916 Info Unity BackendLogin:CustomSingUp(String, String)
2025-07-22 13:45:09.855 19779 19916 Info Unity BackendManager:OnBackendLogin(String, String)
2025-07-22 13:45:09.855 19779 19916 Info Unity <>c__DisplayClass17_1:b__1(Task1) 2025-07-22 13:45:09.855 19779 19916 Info Unity System.Threading.Tasks.Task:Execute() 2025-07-22 13:45:09.855 19779 19916 Info Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) 2025-07-22 13:45:09.855 19779 19916 Info Unity System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&) 2025-07-22 13:45:09.855 19779 19916 Info Unity System.Threading.Tasks.Task:ExecuteEntry(Boolean) 2025-07-22 13:45:09.855 19779 19916 Info Unity System.Threading.ThreadPoolWorkQueue:Dispatch() 2025-07-22 13:45:09.855 19779 19916 Info Unity 2025-07-22 13:45:09.957 19779 19916 Error Unity 회원가입에 실패했습니다. : StatusCode : 400 2025-07-22 13:45:09.957 19779 19916 Error Unity ErrorCode : UndefinedParameterException 2025-07-22 13:45:09.957 19779 19916 Error Unity Message : undefined google_hash, google_hash을(를) 확인할 수 없습니다 2025-07-22 13:45:09.957 19779 19916 Error Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) 2025-07-22 13:45:09.957 19779 19916 Error Unity BackendManager:OnBackendLogin(String, String) 2025-07-22 13:45:09.957 19779 19916 Error Unity <>c__DisplayClass17_1:<Login>b__1(Task
1)
2025-07-22 13:45:09.957 19779 19916 Error Unity System.Threading.Tasks.Task:Execute()
2025-07-22 13:45:09.957 19779 19916 Error Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
2025-07-22 13:45:09.957 19779 19916 Error Unity System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
2025-07-22 13:45:09.957 19779 19916 Error Unity System.Threading.Tasks.Task:ExecuteEntry(Boolean)
2025-07-22 13:45:09.957 19779 19916 Error Unity System.Threading.ThreadPoolWorkQueue:Dispatch()
2025-07-22 13:45:09.957 19779 19916 Error Unity
2025-07-22 13:45:09.957 19779 19916 Info Unity 로그인을 요청합니다.
2025-07-22 13:45:09.957 19779 19916 Info Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
2025-07-22 13:45:09.957 19779 19916 Info Unity BackendLogin:CustomLogin(String, String)
2025-07-22 13:45:09.957 19779 19916 Info Unity BackendManager:OnBackendLogin(String, String)
2025-07-22 13:45:09.957 19779 19916 Info Unity <>c__DisplayClass17_1:b__1(Task1) 2025-07-22 13:45:09.957 19779 19916 Info Unity System.Threading.Tasks.Task:Execute() 2025-07-22 13:45:09.957 19779 19916 Info Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) 2025-07-22 13:45:09.957 19779 19916 Info Unity System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&) 2025-07-22 13:45:09.957 19779 19916 Info Unity System.Threading.Tasks.Task:ExecuteEntry(Boolean) 2025-07-22 13:45:09.957 19779 19916 Info Unity System.Threading.ThreadPoolWorkQueue:Dispatch() 2025-07-22 13:45:09.957 19779 19916 Info Unity 2025-07-22 13:45:10.035 19779 19916 Error Unity 로그인이 실패했습니다. : StatusCode : 400 2025-07-22 13:45:10.035 19779 19916 Error Unity ErrorCode : UndefinedParameterException 2025-07-22 13:45:10.035 19779 19916 Error Unity Message : undefined google_hash, google_hash을(를) 확인할 수 없습니다 2025-07-22 13:45:10.035 19779 19916 Error Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) 2025-07-22 13:45:10.035 19779 19916 Error Unity BackendManager:OnBackendLogin(String, String) 2025-07-22 13:45:10.035 19779 19916 Error Unity <>c__DisplayClass17_1:<Login>b__1(Task
1)
2025-07-22 13:45:10.035 19779 19916 Error Unity System.Threading.Tasks.Task:Execute()
2025-07-22 13:45:10.035 19779 19916 Error Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
2025-07-22 13:45:10.035 19779 19916 Error Unity System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
2025-07-22 13:45:10.035 19779 19916 Error Unity System.Threading.Tasks.Task:ExecuteEntry(Boolean)
2025-07-22 13:45:10.035 19779 19916 Error Unity System.Threading.ThreadPoolWorkQueue:Dispatch()
2025-07-22 13:45:10.035 19779 19916 Error Unity