APK errors

Capacitor sync error

Error text

[error] Could not find the android platform. Make sure android has been added.
[error] capacitor.config.json not found / webDir "www" does not exist

Cause

cap sync cannot copy the web files into the Android project. The Android platform was not added, or the web build folder does not exist.

Step-by-step fix

  1. Build the web project first: npm run build. The webDir folder must appear.
  2. In the capacitor.config file make sure webDir matches the build output (dist, build).
  3. If Android is missing, run npx cap add android.
  4. Then copy the files with npx cap sync android.
  5. Use npx cap doctor to spot version mismatches.

Example commands

npm run build
npx cap add android
npx cap sync android
npx cap open android
npx cap doctor

How to prevent it

Keep the build then sync order in a single script after every web change.

Author and license: Nibras Code