Issue Description
I’m working on a Capacitor-based mobile app using React and React Router. The app works fine on iOS/Xcode, but on Android/Android Studio, external API requests fail with this error:
2025-03-13 06:44:00.628 22016-22116 chromium xxx.xxxx.app E [ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100
- The app loads fine and navigation works.
- However, any external HTTP request to my Vercel-hosted API fails.
- I tried removing and recreating the
android
folder andcapacitor.config.ts
, but the issue persists. - Research suggests that I may need to ignore SSL errors (related thread).
Setup Details
Package.json
{
"name": "mobile-app",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "cd ../mobile-web && pnpm build",
"sync": "cap sync",
"open:ios": "cap open ios",
"open:android": "cap open android",
"add:ios": "cap add ios",
"add:android": "cap add android"
},
"packageManager": "pnpm@10.6.2",
"dependencies": {
"@capacitor/core": "^7.1.0",
"@capacitor/ios": "^7.1.0",
"@capacitor/android": "^7.1.0"
},
"devDependencies": {
"@capacitor/cli": "^7.1.0"
}
}
Capacitor Config (capacitor.config.ts
)
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'xxx.xxxxxx.app',
appName: 'xxxx',
webDir: '../mobile-web/dist',
server: {
cleartext: true,
allowNavigation: ['xxxx.xxx', 'localhost', 'https://xxxx.xxx', 'https://*.xxxx.xxx'],
},
ios: {
contentInset: 'automatic',
preferredContentMode: 'mobile',
backgroundColor: '#000000',
},
android: {},
plugins: {
CapacitorHttp: {
enabled: true,
},
},
};
export default config;
Troubleshooting Steps Tried
- Removed and re-added the Android folder
rm -rf android
pnpm cap sync android
- Checked SSL Certificate
- The API is hosted on Vercel and works fine in the browser.
- Works on iOS, so the issue seems to be Android-specific.
- Checked Network Security Config (potential fix?)
- Should I add a network security config in
res/xml/network_security_config.xml
? - Do I need to allow cleartext traffic?
Questions
- How can I bypass or fix SSL handshake failure in Capacitor for Android?
- Do I need to modify the
android
folder manually to accept self-signed or Let’s Encrypt certificates? - Should I disable SSL checks (even temporarily) for debugging?
Any guidance would be greatly appreciated!