DEV Community

HarmonyOS
HarmonyOS

Posted on

DevEco Studio 5.1 .hap Signing Failure Analysis and Solution Guide

Read the original article:DevEco Studio 5.1 .hap Signing Failure Analysis and Solution Guide

Context

A developer using DevEco Studio 5.1 encountered a blocking issue when trying to build a signed .hap package. Although the AppGallery project, certificates, App ID, and profile were already created, the build process consistently failed at the signing stage with the following error:

> hvigor Finished :entry:default@LegacyGenerateLiteCode... after 318 ms 
> hvigor ERROR: Failed :entry:default@LegacySignLiteBin... 
> hvigor ERROR: Tools execution failed.
11-11 12:54:57.383  WARN - can not sign bin with codesign
11-11 12:54:57.526  ERROR - Sign hap Lite failed.
11-11 12:54:57.526  ERROR - The sign data made failed.
11-11 12:54:57.526  ERROR - Sign bin internal failed.
     Detail: Please check the message from tools.
> hvigor ERROR: BUILD FAILED in 1 s 869 ms
Enter fullscreen mode Exit fullscreen mode

The error message did not provide clear details or guidance on the root cause.

Description

The problem arises during the signing phase of building a HarmonyOS application. Despite correct-looking configuration, DevEco Studio fails to sign the binary, causing the .hap build to stop.

The underlying issue is often related to mismatched or expired signing materials, incorrectly generated key/CSR files, or inconsistencies between the project’s bundle name and the AppGallery configuration.

Because the error message is generic (“Tools execution failed”), additional manual verification is required.

Solution / Approach

To resolve the signing failure, follow the structured steps below:

1. Verify unsigned build first

Try building the project without any signing configuration.

  • Remove all Signing Config settings temporarily.
  • Attempt to build an unsigned .hap.

If the unsigned build succeeds, the issue is confirmed to be related to signing materials rather than code or build configuration.

2. Recreate signing materials in DevEco Studio

Check the Key and CSR files generated inside DevEco Studio:

  • Ensure they were generated correctly.
  • If in doubt, recreate them.
  • Avoid using old or previously exported keys if they might have expired or been misconfigured.

3. Validate AppGallery project data

Inside AppGallery Connect, verify:

Projects

  • Correct project selected.
  • No missing configuration.

Certificates

  • Ensure you are using the Debug certificate, not a Release certificate (unless intentionally building Release).
  • Check expiration dates.

Profiles

  • Confirm that:
    • The package name matches the project bundle name exactly.
    • The profile is not expired.
    • The correct device type and permissions are included.

4. Manually enter signing configuration

Instead of relying on auto-import:

  1. Open Project Structure
  2. Navigate to Signing Configs
  3. Enter the certificate, key, and profile information manually
  4. Save and rebuild

Manually entering details helps avoid cases where DevEco Studio auto-sync fails silently.

1.png

5. Check Bundle Name vs. Package Name

Ensure that the project’s bundle name (in module.json5) matches exactly with the AppGallery package name:

  • No extra spaces
  • No typos
  • Case-sensitive match

This is a common cause for signing failure.

6. Clear DevEco Studio caches

Go to:

File → Invalidate Caches / Restart

This helps when DevEco Studio caches outdated signing materials or project metadata.

Key Takeaways

  • Signing failures in DevEco Studio often occur due to certificate mismatches, expired profiles, or bundle/package name inconsistencies.
  • Always confirm that the AppGallery certificate, profile, and project bundle name are aligned.
  • Testing an unsigned build helps isolate whether the issue is related to signing.
  • Recreating Key & CSR files is often an effective fix if signing tools report unclear errors.
  • Manually entering signing information is more reliable than automatic configuration syncing.
  • Clearing DevEco Studio caches can resolve hidden conflicts caused by old metadata.

Written by Aycanur Ucar

Top comments (0)