Skip to main content

Application Packaging

ElenixOS uses an application packaging tool to package the source code, resources, and configuration files of an application or watch face into a unified installation package (.eapk file). This document will detail the application packaging format, resource organization, and output specifications.

Application Packaging Concept

Application packaging is the process of combining all components of an application (scripts, resources, configuration) into an installable package file. In ElenixOS, the packaged product is a .eapk file, similar to installation package formats on other platforms.

Functions of Packaging

  1. Unified distribution: Package all components of the application into a single file for easy distribution and installation
  2. Resource management: Manage application resource files to ensure correct loading of resources
  3. Version control: Include application version information for easy version management
  4. Permission management: Include application permission information to ensure applications can only access authorized resources

Input Directory Structure

The application packaging tool uses a specific directory structure as input to ensure the consistency and reliability of the packaging process.

Standard Directory Structure

app/
├── manifest.json # Application configuration file
├── main.js # Application main script
├── icon.bin # Application icon
├── assets/ # Resource directory
│ ├── images/ # Image resources
│ ├── fonts/ # Font resources
│ └── sounds/ # Audio resources
└── lib/ # Dependency libraries

Directory Description

  • manifest.json: Application configuration file, containing application ID, name, version, type, etc.
  • main.js: Application main script file, containing application interface and logic
  • icon.bin: Application icon file, used to display in the application list
  • assets/: Application resource directory, containing images, fonts, audio, etc.
  • lib/: Application dependency library directory, containing third-party libraries and modules

Packaging Product Format

ElenixOS's application packaging product is a .eapk file, which is a compressed file containing all components of the application.

.eapk File Structure

app.eapk/
├── manifest.json # Application configuration file
├── main.js # Application main script
├── icon.bin # Application icon
├── assets/ # Resource directory
└── lib/ # Dependency libraries

Packaging Tool

ElenixOS uses the Python script scripts/eos_pkg_builder.py for application packaging:

python3 scripts/eos_pkg_builder.py --input app/ --output app.eapk

Resource Merging Rules

During the packaging process, resource files are merged and processed according to certain rules:

Resource File Processing

  1. Image resources: Support PNG, JPG and other formats, will be compressed
  2. Font resources: Support TTF, OTF and other formats, will be optimized
  3. Audio resources: Support WAV, MP3 and other formats, will be compressed

Dependency Library Processing

  1. JavaScript modules: Will be merged and optimized
  2. Native libraries: Will be properly processed to ensure they are available on the target platform

Configuration File Processing

  1. manifest.json: Will be verified and processed to ensure correct format
  2. Other configuration files: Will be copied to the packaged product

Release and Deployment Methods

Release Process

  1. Develop application: Develop application source code and resources
  2. Package application: Use packaging tools to generate .eapk files
  3. Test application: Test the application on test devices
  4. Release application: Release the application to the application store or other distribution channels

Deployment Methods

  1. Local installation: Copy the .eapk file to the device through the file system, then use the application management API to install
  2. Remote installation: Download the .eapk file to the device through the network, then use the application management API to install
  3. OTA update: Update the application through OTA (Over-The-Air) method

Deployment Commands

# Local installation
eas_app_install("/path/to/app.eapk");

# Remote installation (example)
download_file("https://example.com/app.eapk", "/tmp/app.eapk");
eas_app_install("/tmp/app.eapk");

Packaging Tool Usage

Packaging Tool Parameters

ParameterDescriptionExample
--inputInput directory path--input app/
--outputOutput file path--output app.eapk
--compressCompression level (0-9)--compress 9
--verboseDetailed output--verbose

Running Examples

# Basic packaging
python3 scripts/eos_pkg_builder.py --input app/ --output app.eapk

# Packaging with compression
python3 scripts/eos_pkg_builder.py --input app/ --output app.eapk --compress 9

# Detailed output
python3 scripts/eos_pkg_builder.py --input app/ --output app.eapk --verbose

Application Configuration File

manifest.json Format

{
"id": "com.example.app",
"name": "Example Application",
"version": "1.0.0",
"type": "application",
"author": "Example Developer",
"description": "This is an example application",
"icon": "icon.bin",
"main": "main.js",
"permissions": [
"battery",
"sensor"
],
"resources": {
"images": [
"assets/images/logo.png"
],
"fonts": [
"assets/fonts/font.ttf"
]
}
}

Configuration Field Description

  • id: Application's unique identifier, format: com.example.app
  • name: Application's display name
  • version: Application's version number, format: x.y.z
  • type: Application type, application or watchface
  • author: Application's developer
  • description: Application's description
  • icon: Application's icon file
  • main: Application's main script file
  • permissions: Permissions required by the application
  • resources: Application's resource files

Best Practices

  1. Directory structure: Follow the standard directory structure to ensure the packaging tool can correctly identify and process files
  2. Resource management: Organize resource files reasonably to avoid oversized resource files
  3. Configuration files: Ensure the manifest.json file is in correct format and contains all necessary fields
  4. Version control: Use semantic version numbers for easy version management and updates
  5. Permission management: Only apply for necessary permissions for the application, avoid excessive permission requests

Common Issues and Solutions

Packaging Failure

Issue: Packaging tool execution fails

Solutions:

  1. Check if the input directory structure is correct
  2. Check if the manifest.json file format is correct
  3. Check if resource files exist

Installation Failure

Issue: Application installation fails

Solutions:

  1. Check if the .eapk file is damaged
  2. Check if the application's permissions are correct
  3. Check if the device has enough storage space

Runtime Errors

Issue: Application runtime errors

Solutions:

  1. Check if the application's scripts have syntax errors
  2. Check if the application's resource files are correctly loaded
  3. Check if the application's permissions are granted

Summary

Application packaging is an important part of ElenixOS application development, which combines all components of the application into an installable package file. By understanding the application packaging format, resource organization, and output specifications, developers can better manage and distribute applications.

ElenixOS's application packaging tool provides a simple and efficient way to package applications, ensuring that applications can be correctly installed and run on different devices. By following best practices, developers can create high-quality application packages and provide users with a good application experience.