Flutter에서 Google 로그인 구현 중, Android에서 아래와 같은 오류가 발생:
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null, null)
이 오류의 근본 원인은 google_sign_in 패키지에서 Android 플랫폼에 clientId를 명시적으로 전달했기 때문이다.
clientId 명시 시 Android에서 발생하는 문제clientId를 넘기면 그것을 서버용 클라이언트 ID(serverClientId) 로 해석한다.ApiException: 10 에러가 발생함
google_sign_in패키지는google-services.json을 통해 자동으로 클라이언트를 설정하므로 Android에서는clientId를 절대 직접 지정하면 안 된다.
GoogleSignIn(
clientId: dotenv.env['GOOGLE_CLIENT_ID'], // ❌ Android에서 사용 시 오류 발생ios도 안됨
scopes: ['email'],
);
해결 방법
✅ clientId 직접 넘기지 않기
GoogleSignIn(
scopes: ['email'],
);
✅ 혹은 플랫폼 분기 처리
GoogleSignIn(
clientId: Platform.isIOS ? dotenv.env['GOOGLE_CLIENT_ID'] : null,
scopes: ['email'],
);
이방법 잘안됨 결국 다지워야됨
---