Troubleshooting
Common issues and solutions for CodePush deployment problems
Common Issues & Solutions
Quick solutions to the most common CodePush integration and deployment problems.
Installation & Setup Issues
npm install -g code-push-cli
returns permission errors or fails to install.
# Use npm prefix to install globally without sudo npm config set prefix ~/.npm-global export PATH=~/.npm-global/bin:$PATH npm install -g code-push-cli # Or use npx to run without installing npx code-push-cli login http://your-server.com
CodePush not found after installation in React Native 0.60+.
# Clean and rebuild cd ios && rm -rf Pods && pod install && cd .. npx react-native run-ios # For Android cd android && ./gradlew clean && cd .. npx react-native run-android # Verify linking npx react-native config
Authentication Issues
CLI commands fail with authentication errors.
# Re-login to refresh token code-push logout code-push login http://your-server.com # Check current authentication code-push whoami # Use access key directly code-push login --accessKey YOUR_ACCESS_KEY
Cannot access admin dashboard or authentication fails.
- Verify Firebase project configuration
- Check Firebase console for enabled auth methods
- Ensure correct Firebase config in admin dashboard
- Clear browser cache and cookies
- Check network connectivity to Firebase
Deployment Issues
Deployed updates are not being downloaded or installed on test devices.
// Add debugging to your app import CodePush from 'react-native-code-push'; CodePush.sync({ updateDialog: true, installMode: CodePush.InstallMode.IMMEDIATE }, (status) => { console.log('CodePush status:', status); }, (progress) => { console.log('Download progress:', progress); }); // Check deployment key console.log('Deployment key:', 'YOUR_DEPLOYMENT_KEY'); // Verify server connectivity CodePush.checkForUpdate().then(update => { console.log('Update available:', update); });
Updates fail to install due to hash verification errors.
- Clear app data and restart
- Redeploy the update package
- Check for corrupted files in build process
- Verify network stability during upload
- Try releasing a new version
Updates fail because they don't target the correct app version.
# Check your app's current version # iOS: CFBundleShortVersionString in Info.plist # Android: versionName in build.gradle # Deploy with correct target version code-push release-react MyApp ios --targetBinaryVersion "1.2.0" # Or use semver range code-push release-react MyApp ios --targetBinaryVersion ">=1.0.0 <2.0.0"
Platform-Specific Issues
// Ensure AppDelegate.m has correct bundle URL #import <CodePush/CodePush.h> - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [CodePush bundleURL]; #endif }
- Clean Xcode build folder (⇧⌘K)
- Delete
ios/build
folder - Run
pod install
in ios folder - Restart Xcode and rebuild
// Check MainApplication.java configuration public class MainApplication extends Application implements ReactApplication { @Override protected String getJSBundleFile() { return CodePush.getJSBundleFile(); } @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG) ); } }
# Clean and rebuild cd android ./gradlew clean cd .. npx react-native run-android # If issues persist, delete node_modules and reinstall rm -rf node_modules npm install
Performance Issues
Updates take too long to download due to large bundle sizes.
- Enable bundle splitting and optimization
- Remove unused assets and dependencies
- Use image compression and WebP format
- Implement lazy loading for non-critical features
- Consider binary updates for major changes
App becomes slow or crashes after CodePush updates.
// Restart app after update for clean memory state CodePush.sync({ installMode: CodePush.InstallMode.ON_NEXT_RESTART, minimumBackgroundDuration: 60000 }); // Or restart immediately for critical updates CodePush.restartApp(true);
Network Issues
Downloads timeout or fail on poor network connections.
const codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_START, installMode: CodePush.InstallMode.ON_NEXT_RESTART, // Add retry logic and longer timeouts deploymentKey: 'your-key', serverUrl: 'your-server', timeoutMilliseconds: 60000 // 60 seconds }; export default CodePush(codePushOptions)(App);
Server Configuration Issues
Admin dashboard cannot connect to CodePush server due to CORS policy.
// Update server CORS configuration const cors = require('cors'); app.use(cors({ origin: [ 'https://dashboard.codepush.online', // Admin dashboard 'https://your-domain.com' // Production URL ], credentials: true }));
Debugging Tools
// Add to your App component for detailed logging import CodePush from 'react-native-code-push'; class App extends Component { componentDidMount() { CodePush.sync( { updateDialog: true }, (status) => { console.log('[CodePush] Status:', this.getStatusText(status)); }, (progress) => { console.log('[CodePush] Progress:', Math.round(progress.receivedBytes / progress.totalBytes * 100) + '%'); } ); } getStatusText(status) { switch(status) { case CodePush.SyncStatus.CHECKING_FOR_UPDATE: return "Checking for update"; case CodePush.SyncStatus.DOWNLOADING_PACKAGE: return "Downloading package"; case CodePush.SyncStatus.INSTALLING_UPDATE: return "Installing update"; case CodePush.SyncStatus.UP_TO_DATE: return "App up to date"; case CodePush.SyncStatus.UPDATE_INSTALLED: return "Update installed"; default: return "Unknown status"; } } }
Getting Help
- CodePush CLI version (
code-push --version
) - React Native version
- Platform (iOS/Android) and OS version
- Complete error messages and stack traces
- Steps to reproduce the issue
- Relevant configuration files
Still Need Help?
If these solutions don't resolve your issue, check the documentation or contact support.