All Products
Document Center

Use Material Design

Last Updated: Feb 10, 2022

This topic introduces how to use Material Design from aspects of project configuration and resource usage.

Configure a project

About this task

Due to the special nature of the mPaaS framework, if an AppCompat related library is directly imported into your project, there will be an compilation error indicating that resources cannot be found. To solve this problem, the mPaaS provides a custom AppCompat library. To use the customized AppCompat library by the mPaaS, configure the Portal and Bundle projects.

The mPaaS AppCompat library is developed based on the native Android version 23 and includes the following components:

  • appcompat
  • animated-vector-drawable
  • cardview
  • design
  • recyclerview
  • support-vector-drawable

Compiled based on the native Android version 23, this custom AppCompat library is the same as the native library. But this solution can solve a number of compilation issues associated if you use the native library.

Use of resources mainly includes using resources in another Bundle, making resources available for external devices, and using custom resources in AndroidManifest. Due to the special nature of the mPaaS framework, you need to understand the considerations when different resources are used. For more information, refer to Use resources.


  1. Configure a Portal project.

    Before invoking the mPaaS AppCompat, perform the following operations to configure a Portal project:
    1. Run the following command to replace the Gradle package plug-in (Alipay Plugin for Gradle) version with the following version:
      classpath ''
    2. Remove the AppCompat library that previously depends on from the Gradle script.
    3. Add the following AppCompat dependencies to the Gradle script:
      bundle ''
      manifest ''
    4. After completing the configuration, make the Bundle project invoke the AppCompat component to synchronize the Portal project.
  2. Configure a Bundle project

    1. In a Bundle project that uses the AppCompat component, change the Gradle package plug-in (Alipay Plugin for Gradle) to the following version:

      classpath ''
    2. Select the sub-component to depend on according to the component you use. The following shows the sample statement to add recyclerview:


Use resources

Common resources for material design include strings, colors and styles. Scenarios where resources are used include:

Check whether Package ID is duplicate

If the resource cannot be found while you use it as described in this topic, you need to check to check whether the Package ID is duplicate. Package ID is defined in build.gradle and the value of this ID is related to the ID of the resulting resource. Resources cannot be found when Package ID is duplicate.

You can check whether Package ID is duplicate by using the following two methods:

Method 1: Perform auto detection by running Gradle task


The version of android-gradle-plugin is or later versions. e.g.

classpath ''
Test procedure
  1. Execute the following commands under the root directory of a Portal project:
    • For the Windows operating system: Executes gradlew.bat checkBundleIds.
    • For other operating systems: Executes gradlew checkBundleIds.
  2. Test result:
    • If the test result indicates No duplicate bundle ids found, Package ID is not duplicate.
    • If the test result indicates There are duplicate bundle ids, Package ID is duplicate. You can further determine which Package IDs are duplicate based on the test result.

Method 2: Perform test mannually

Manual test applies in any case. The test procedure is as follows:

  1. In the following location of a Portal project, open the bundles.csv plain text file.

  2. Sort the PackageId column, and check whether Package ID is duplicate. Make sure there are no duplicate Package IDs before recompilation.

Use the resource in another Bundle

Typical scenario

This is the case with using the resource in mpaas-baseresjar. When using the resource in another Bundle, you must append the namespace of the resource. The namespace is the applicationID of the Bundle in which the resource resides. An error may occur when you build a release package, as shown in the following figure:


In build.gradle, configure lintOptions, as shown in the following figure:

You must prefix resources with a namespace whenever references are made to resources in this Bundle (in layouts, in custom styles). Otherwise, a compilation error indicating that resources cannot be found will occur.

Sample code: references in layouts

Taking the reference to a resource in another Bundle in layouts as an example, check the following sample code:

<?xml version="1.0" encoding="utf-8"?>
< xmlns:android=""



                app:layout_collapseMode="parallax" />

                app:popupTheme="@style/AppTheme.PopupOverlay" />


        app:layout_anchorGravity="bottom|end" />

    <include layout="@layout/content_scrolling" />


Sample code: references in custom styles

When you use the resource in another Bundle in the custom style, the code sample is shown as follows:

<style name="AppTheme" parent="">
        <!-- Customize your theme here. -->
        <item name="">@color/colorPrimary</item>
        <item name="">@color/colorPrimaryDark</item>
        <item name="">@color/colorAccent</item>

Provide resources for external devices

  1. Configure a Portal project. Import the information about the resource Bundle into Portal:
    // Import the resource Bundle
    bundle "com.mpaas.demo.materialdesign:materialdesign-build:1.0-SNAPSHOT:raw@jar"
    manifest "com.mpaas.demo.materialdesign:materialdesign-build:1.0-SNAPSHOT:AndroidManifest@xml"
    // To find resources when compiling, you need the JAR package of this Bundle.
    provided 'com.mpaas.demo.materialdesign:materialdesign-build:1.0-SNAPSHOT:raw@jar'
  2. Define resources. Complete the following steps to define a resource so that the resource can be referenced by another Bundle or Portal:

    1. Define the resource ID that need to be supplied to an external device in public.xml for the purpose of fixing the resource ID. This capability is provided by Android. The resource ID value can be copied from The code sample is shown as follows:

      <?xml version="1.0" encoding="utf-8"?>
        <public name="AppTheme" id="0x1f030000" type="style" />
        <public name="AppTheme.AppBarOverlay" id="0x1f030001" type="style" />
        <public name="AppTheme.NoActionBar" id="0x1f030002" type="style" />
        <public name="AppTheme.NoActionBar.StatusBar" id="0x1f030003" type="style" />
        <public name="AppTheme.PopupOverlay" id="0x1f030004" type="style" />
        <public name="DialogFullscreen" id="0x1f030005" type="style" />
        <public name="DialogFullscreenWithTitle" id="0x1f030006" type="style" />
        <public name="title_activity_login" id="0x1f0c0081" type="string"/>
        <public name="title_activity_recycler_view" id="0x1f0c0082" type="string"/>
        <public name="title_activity_share_view" id="0x1f0c0085" type="string"/>
        <public name="title_activity_scrolling" id="0x1f0c0083" type="string"/>
        <public name="title_activity_settings" id="0x1f0c0084" type="string"/>
        <public name="title_activity_about" id="0x1f0c007f" type="string"/>
        <public name="activity_donate" id="0x1f0c000e" type="string" />
        <public name="activity_my_apps" id="0x1f0c000f" type="string"/>
    2. When a resource is being used by an external device, the resource must be prefixed with a package name. For more information, see Use the resource in another Bundle.

Use custom resources in AndroidManifest

If you define a theme in AndroidManifest of your Bundle project, the code sample is shown as follows:


You need to:

  • Add the res_slinks file in the main path of the Portal project, and add Bundle names to the res_slinks file line by line.
  • At the same time, remove the manifest dependency of this Bundle from build.gradle. As shown in the following code:
    manifest 'com.mpaas.demo.materialdesign:materialdesign-build:1.0.0:AndroidManifest@xml'