shwenzhang/AndResGuard · error · java.io.IOException
can not found the raw apk file to zipalign, path=
Error message
can not found the raw apk file to zipalign, path=%s
What it means
alignApk zipaligns the APK at path 'before' into 'after'. If the input APK does not exist on disk, this IOException with the absolute path is thrown. It is a pre-condition guard so that zipalign is never run against a missing file (which would otherwise produce a confusing native command error).
Solutions
- Check earlier build log lines for the failed signing/packaging step and fix its root cause
- Verify the APK path printed in the message exists and that your output/outDir configuration matches where the build writes APKs
- Re-run the build from a clean state so the unsigned/signed APK is regenerated before zipalign
- If zipalign should not be needed, confirm config.mUseSignAPK is set consistently with your pipeline
Example fix
// before: signing skipped but zipalign attempted with stale path
// after: verify the file exists before invoking the builder
File apk = new File(outDir, "app-unsigned.apk");
if (!apk.exists()) { throw new IllegalStateException("unsigned APK missing: " + apk); }
andResGuard.build(); Defensive patterns
Strategy: try-catch
Validate before calling
File apk = new File(expectedApkPath);
if (!apk.isFile()) throw new IllegalStateException("APK to zipalign does not exist: " + apk.getAbsolutePath()); Try / catch
try {
andResGuard.build();
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().startsWith("can not found the raw apk file to zipalign")) {
throw new IllegalStateException("upstream build/signing step did not produce the APK at " + e.getMessage(), e);
}
throw e;
} Prevention
- Make sure the signing/packaging step succeeds before alignment (fix earlier log errors)
- Keep outDir/zipalign path configuration consistent with where APKs are written
- Avoid running clean tasks concurrently with the build
- Re-run from a clean state after any failed build so intermediate APKs are regenerated
When it happens
Trigger: Called from alignApks or buildApkWithV2V3Sign when the raw/signed APK expected at the given path was never produced or was deleted — e.g. the signing or packaging step silently failed, or config points at the wrong output directory.
Common situations: A previous build step failed but the pipeline continued; a custom mZipalignPath/outPath configuration points at a directory that does not match where the APK was written; the unsigned APK was removed by a clean task running concurrently.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Can not found any signed apk file
- Can't Generate signed APK. Plz check your v1sign info is…
- Can't Generate signed APK v2. Plz check your v2sign info is…
- private key is not a DSA or RSA key
- can not found the raw apk file to zipalign, path=
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/a4ecba7ea3b36d23.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java:287
//如果不签名就肯定不需要对齐了
if (!config.mUseSignAPK) {
return;
}
if (!mSignedApk.exists() && !mSignedWith7ZipApk.exists()) {
throw new IOException("Can not found any signed apk file");
}
if (mSignedApk.exists()) {
alignApk(mSignedApk, mAlignedApk);
}
if (mSignedWith7ZipApk.exists()) {
alignApk(mSignedWith7ZipApk, mAlignedWith7ZipApk);
}
}
private void alignApk(File before, File after) throws IOException, InterruptedException {
System.out.printf("zipaligning apk: %s, exists:%b\n", before.getAbsolutePath(), before.exists());
if (!before.exists()) {
throw new IOException(String.format("can not found the raw apk file to zipalign, path=%s",
before.getAbsolutePath()
));
}
String cmd = Utils.isPresent(config.mZipalignPath) ? config.mZipalignPath : TypedValue.COMMAND_ZIPALIGIN;
Utils.runCmd(cmd, "4", before.getAbsolutePath(), after.getAbsolutePath());
if (!after.exists()) {
throw new IOException(String.format("can not found the aligned apk file, the ZipAlign path is correct? path=%s",
mAlignedApk.getAbsolutePath()
));
}
}
private void generalUnsignApk(HashMap<String, Integer> compressData) throws IOException, InterruptedException {
System.out.printf("General unsigned apk: %s\n", mUnSignedApk.getName());
File tempOutDir = new File(mOutDir.getAbsolutePath(), TypedValue.UNZIP_FILE_PATH);
if (!tempOutDir.exists()) {
System.err.printf("Missing apk unzip files, path=%s\n", tempOutDir.getAbsolutePath());
System.exit(-1);View on GitHub (pinned to e4df245d82)