El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Building with Android

Updated on 2024-11-21 GMT+08:00

The Android build system compiles application resources and source code, and then packages them into APKs that can be deployed, signed, and distributed.

Build on GUI

  1. Add Build with Android, when configuring build actions. Set the parameters according to Table 1.
    Table 1 Parameters for building with Android

    Parameter

    Description

    Action Name

    Assign a custom name to the build action. The name can contain:

    • Letters, digits, hyphens (-), underscores (_), commas (,), semicolons (;), colons (:), periods (.), slashes (/), and parentheses.
    • 1 to 128 characters.

    Gradle

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    JDK

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    NDK

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    Commands

    Configure the Gradle commands, or use the default ones. For more commands, see the Gradle official website.

    Continue After Failure

    Specify whether to proceed after the current action fails by setting the parameter to either Yes or No.

  2. If you need to use apksigner to sign Android APKs, add the Sign Android APK action and configure the parameters according to the following table.

    Parameter

    Description

    Action Name

    Assign a custom name to the build action. The name can contain:

    • Letters, digits, hyphens (-), underscores (_), commas (,), semicolons (;), colons (:), periods (.), slashes (/), and parentheses.
    • 1 to 128 characters.

    APK Location

    Location of the .apk file to be signed after the Android build.

    You can use regular expressions, such as build/bin/*.apk, to match the built APK package.

    Keystore File

    Select the keystore file used for signature from the drop-down list. For details about how to create and upload the file, see Generating the Keystore Signature File and Uploading It for Management.

    Keystore Password

    Optional.

    Enter the custom password of the keystore file.

    Alias

    Assign a custom alias to the key.

    • The value must start with a letter and can contain letters, digits, underscores (_), hyphens (-), and periods (.).
    • The value contains 1 to 128 characters.

    Key Password

    Optional.

    Enter a custom key password.

    Apksigner Command

    Enter a custom signature parameter. By default, --verbose is added to display the signature details.

    Continue After Failure

    Specify whether to proceed after the current action fails by setting the parameter to either Yes or No.

    Once you have finished configuration, run the build task. If the task is executed successfully, check the build logs. If the logs of the Sign Android APK action display Signed, it means that the signing process was successful.

Build with Code

Modify the code in the BUILD block in Creating a YAML File for Your Code-based Build by referring to the following sample code:

  1. The following sample code is for the Android build:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    version: 2.0 # The value must be 2.0.
    steps:
      BUILD:
        - android:
            inputs:
              gradle: 4.8 
              jdk: 1.8
              ndk: 17
              command: | 
                cat ~/.gradle/init.gradle
                cat ~/.gradle/gradle.properties
                cat ~/.gradle/init_template.gradle
                rm -rf ~/.gradle/init.gradle
                rm -rf /home/build/.gradle/init.gradle
                # Gradle Wrapper provided by CodeArts Build is used for cache acceleration.
                cp /cache/android/wrapper/gradle-wrapper.jar ./gradle/wrapper/gradle-wrapper.jar
                # Build an unsigned APK.
                /bin/bash ./gradlew assembleDebug -Dorg.gradle.daemon=false -d --stacktrace
             ignore_fail: true
    
    Table 2 Parameters in the sample code for the Android build

    Parameter

    Type

    Description

    command

    String

    Enter the Gradle command. For more commands, see the Gradle official website.

    gradle

    String

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    jdk

    String

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    ndk

    String

    Select a tool version that matches your current development environment.

    For tool versions supported by CodeArts Build, see build tools and versions. If the current tools and versions do not meet your requirements, you can customize a build environment.

    ignore_fail

    String

    Whether to proceed after the current action fails.
    • true: Yes
    • Empty: No
  2. The following sample code is to sign the Android APK.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    version: 2.0 # The value must be 2.0.
    steps:
      BUILD:
        - android_sign:
                inputs:
                   file_path: build/bin/*.apk
                       keystore_file: androidapk.jks
                       keystore_password: xxxxxx
                       alias: keyalias
                       key_password: xxxxxx
                       apksigner_commond: --verbose
                       ignore_fail: true
    
    Table 3 Parameters in the sample code for signing the Android APK

    Parameter

    Type

    Description

    file_path

    String

    Location of the .apk file to be signed after the Android build.

    You can use regular expressions, such as build/bin/*.apk, to match the built APK package.

    keystore_file

    String

    Name of the keystore file. For details about how to create and upload the file, see Generating the Keystore Signature File and Uploading It for Management.

    keystore_password

    String

    Optional.

    Enter the custom password of the keystore file.

    alias

    String

    Alias of the keystore file.

    • The value must start with a letter and can contain letters, digits, underscores (_), hyphens (-), and periods (.).
    • The value contains 1 to 128 characters.

    key_password

    String

    Optional.

    Enter a custom key password.

    apksigner_commond

    String

    Enter a custom signature parameter. By default, --verbose is added to display the signature details.

    ignore_fail

    String

    Whether to proceed after the current action fails.
    • true: Yes
    • Empty: No

Android Version Description

  • SDK: used to specify compileSdkVersion.
  • Build Tools: used to specify buildToolsVersion.

You can find the two versions in the build.gradle file or the global configuration file (user-defined) of the project.

NOTE:
  • Select compileSdkVersion or buildToolsVersion based on project requirements.
  • The Gradle wrapper build mode is also supported. If the provided Gradle version does not meet your requirements, you can run the gradlew command for build using the wrapper. The required Gradle version will be automatically downloaded. Example of the build command: ./gradlew clean build.

Generating the Keystore Signature File and Uploading It for Management

  1. The keystore signature file can be generated in either of the following ways:
    • Using Keytool in JDK to Generate Signature Files
      1. Find the JDK installation path and run keytool.exe.

      2. Run the following command to generate a .jks file:
        keytool -genkeypair -storepass 123456 -alias apksign -keypass 123456 -keyalg RSA -validity 20000 -keystore D:/android.jks

    • Using Android Studio to Generate Signature Files
      1. Open the Studio client and choose Build > Generate Signed Bundle/APK.

      2. Select APK and click Next.
      3. Click Create new.... In the displayed dialog box, enter related information, and click OK. Then click Next.

      4. View the generated signature file.

  2. You can upload the keystore signature file to the Files page in either of the following ways:
    • In the Build with Android action, click Upload next to Keystore File. In the displayed dialog box, select a file, add a description, select the related agreements, and click Save.
    • On the CodeArts Build homepage, choose More > Files. On the displayed page, click Upload File. In the displayed dialog box, select a file, add a description, select the related agreements, and click Save.
    On the Files page, you can edit, download, and delete files, as well as configure operation permissions for other users.
    • Enter a keyword in the search box to search for a file.
    • Click in the Operation column to modify the file name and specify whether to allow all members of your account to use the file in CodeArts Build.
    • Click in the Operation column to download the file.
    • Click in the Operation column and select Delete from the drop-down list. Confirm the deletion as prompted.
    • Click in the Operation column and select Modify Permissions from the drop-down list. In the displayed dialog box, configure file operation permissions for the user.
      Figure 1 Configuring file operation permissions for a user
      Table 4 Roles and their permissions on files

      Permission

      Role with the Permission

      Add users

      All users in the project

      View a file

      File creator and users under the same account

      Use a file

      File creator and users with the use permissions configured by the file creator

      Update a file

      File creator and users with the update permissions configured by the file creator

      Delete a file

      File creator and users with the delete permissions configured by the file creator

      Modify permissions

      File creator

      NOTE:

      By default, the creator has all permissions, which cannot be deleted or modified.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback