A complete React Native Android app demonstrating Google Sign-In integration with proper error handling and debugging solutions.
This repository contains a working React Native Android app that successfully implements Google OAuth authentication. Based on real debugging experience, this project solves the most common Google Sign-In integration issues.
- Google Sign-In Integration using
@react-native-google-signin/google-signin
- Complete OAuth Flow - Sign in and Sign out functionality
- User Profile Display - Name, Email, Profile Photo, and User ID
- Proper Error Handling - Handles all common Google Sign-In errors
- Real Device Testing - Tested and working on physical Android devices
- Debug Logging - Console outputs for troubleshooting
- Modern React Native - Built with latest React Native and TypeScript
- React Native (Latest version)
- TypeScript for type safety
- @react-native-google-signin/google-signin library
- React Native Safe Area Context for proper layout
- Google Cloud Console OAuth configuration
- Firebase project integration
The app displays:
- Welcome screen with "Sign In with Google" button
- User profile after successful authentication showing:
- Profile photo
- Welcome message with user's name
- Email address
- User ID
- Sign out button
- Node.js (14 or later)
- React Native development environment
- Android Studio and SDK
- Physical Android device or emulator
- Clone the repository:
git clone https://github.com/salmanazamdev/react-native-auth.git
cd react-native-auth
- Install dependencies:
npm install
- Android Setup:
cd android
./gradlew clean
cd ..
- Create Google Cloud Project
- Set up Firebase project
- Create Web OAuth Client (use this ID in App.tsx)
- Create Android OAuth Client with your package name and SHA-1
- Download google-services.json and place in
android/app/
- Current package name:
com.reactnativeauth.test
- You can change this in
android/app/build.gradle
βapplicationId
This project addresses the most frustrating Google Sign-In errors:
- Issue: Missing Android OAuth client configuration
- Solution: Proper SHA-1 fingerprint setup and Android client creation
- Issue: OAuth client conflicts in Google Cloud Console
- Solution: Using unique package name (
com.reactnativeauth.test
)
- Issue: google-services.json doesn't match package name
- Solution: Updated Firebase configuration for current package name
- Issue: Wrong user data structure access
- Solution: Correct data path (
userInfo.data.user.name
)
- Issue: Deprecated package attribute in AndroidManifest.xml
- Solution: Removed package attribute (modern Android requirement)
react-native-auth/
βββ App.tsx # Main app component with Google Sign-In
βββ android/
β βββ app/
β β βββ build.gradle # Package name configuration
β β βββ google-services.json # Firebase configuration
β β βββ src/main/AndroidManifest.xml # Android manifest
βββ package.json # Dependencies and scripts
βββ README.md # This file
- Google Sign-In configuration with Web Client ID
- Complete authentication flow implementation
- User data display with proper data structure handling
- Error handling for all common scenarios
- Package name:
com.reactnativeauth.test
- Google Services plugin configuration
- Proper dependency management
- Clean manifest without deprecated package attribute
- Modern Android configuration
GoogleSignin.configure({
webClientId: 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com',
offlineAccess: true,
});
// Handles the correct data structure returned by Google Sign-In
const userData = userInfo.data?.user;
const name = userData?.name;
const email = userData?.email;
const photo = userData?.photo;
// Handles all Google Sign-In error scenarios
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log('User cancelled the login flow');
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log('Play services not available or outdated');
}
- Working Google OAuth Implementation - Complete sign-in/sign-out flow
- Real-world Debugging Solutions - Based on actual development challenges
- Proper Error Handling - Graceful handling of all authentication scenarios
- Modern React Native Patterns - TypeScript, hooks, and best practices
- Production-Ready Code - Clean, maintainable, and well-documented
- Start Metro bundler:
npm start
- Run on Android:
npm run android
- For debugging:
npx react-native log-android
The app includes comprehensive logging to help troubleshoot issues:
User Info: { type: 'success', data: { user: { name: '...', email: '...' } } }
Full user object: { ... detailed JSON structure ... }
- Clone repository
- Install dependencies (
npm install
) - Create Google Cloud OAuth clients (Web + Android)
- Generate SHA-1 fingerprint for Android client
- Download google-services.json from Firebase
- Update Web Client ID in App.tsx
- Run
npm run android
Found an issue or want to improve the implementation? Feel free to:
- Open an issue for bugs or questions
- Submit pull requests for improvements
- Share your debugging experiences
Salman Azam - GitHub
Built with β€οΈ and lots of debugging sessions!
β If this repository helped you implement Google Sign-In, please give it a star!