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

Problem: CLI installation fails

npm install -g code-push-cli returns permission errors or fails to install.

Solutions:
# 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
Problem: React Native auto-linking not working

CodePush not found after installation in React Native 0.60+.

Solutions:
# 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

Problem: "Unauthorized" or "Invalid token" errors

CLI commands fail with authentication errors.

Solutions:
# 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
Problem: Firebase authentication issues

Cannot access admin dashboard or authentication fails.

Solutions:
  • 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

Problem: Updates not appearing on device

Deployed updates are not being downloaded or installed on test devices.

Debugging Steps:
// 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);
});
Problem: "Package hash mismatch" errors

Updates fail to install due to hash verification errors.

Solutions:
  • 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
Problem: "Binary version mismatch" errors

Updates fail because they don't target the correct app version.

Solutions:
# 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

iOS Issues
Problem: Bundle not found in release builds
// 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
}
Problem: Build fails with CodePush
  • Clean Xcode build folder (⇧⌘K)
  • Delete ios/build folder
  • Run pod install in ios folder
  • Restart Xcode and rebuild
Android Issues
Problem: App crashes on startup after CodePush integration
// 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)
        );
    }
}
Problem: Gradle build fails
# 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

Problem: Large bundle sizes causing slow downloads

Updates take too long to download due to large bundle sizes.

Optimization strategies:
  • 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
Problem: Memory issues after updates

App becomes slow or crashes after CodePush updates.

Solutions:
// 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

Problem: Updates fail on slow/unreliable networks

Downloads timeout or fail on poor network connections.

Configuration:
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

Problem: CORS errors in admin dashboard

Admin dashboard cannot connect to CodePush server due to CORS policy.

Solutions:
// 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

Enable Debug Logging
// 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

When reporting issues, include:
  • 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.