To use the component-based method, complete the following steps:
Create a new project on the client
This topic shows you how to create a new app in a Windows development environment. You will compile and package the app to create a runnable .apk package.
Before you create a new project on the client, complete the following tasks:
Create a Portal project
The component-based solution uses the Portal-Bundle method. You must first create a Portal project.
A Portal project usually contains no business code. Its purpose is to merge Bundles into a runnable .apk package. When you create a Portal project, a Bundle project with the Launcher suffix is created by default.
Follow these steps:
After you start Android Studio, click Start a new mPaaS project on the welcome page.
In the Create New mPaaS Project window, select mPaaS Portal. Click Next.
Enter a Project name. For Path of configuration file (JSON) from console, select the .config configuration file that you downloaded from Code Management > Code Configuration in the console. The mPaaS plug-in automatically parses the configuration file and populates the Package Name. Click Next.
Select the mPaaS SDK version and select the required module dependencies. Click Next.
ImportantSelect module dependencies as needed. For more information about dependencies, see the integration document for each component.
You can also select only the required framework dependencies. After you create the application, you can add other required dependencies using the mPaaS plug-in > Component Management feature. For more information, see the integration document for each component.
Confirm the information for the default Bundle project. Click Finish.
You have now created a Portal project and a default Bundle project.
Create a new Bundle project
The mPaaS framework supports multiple Bundles. You can add multiple Bundle projects to your project.
Click File > New > Start a New mPaaS Project.
In the Create New mPaaS Project window, select mPaaS Portal. Click Next.
Enter a Project name. For Path of configuration file (JSON) from console, select the .config configuration file that you downloaded from Code Management > Code Configuration in the console. The mPaaS plug-in automatically parses the configuration file and populates the Package Name. Click Next.
Select the mPaaS SDK version and select the required module dependencies. Click Next.
Confirm the information for the default Bundle project. Click Finish.
You have now created a Bundle project. For more information about Bundle development, see Bundle project.
What to do next
Refer to the integration document for each component to integrate and use mPaaS components.
Related links
Component-based method > Introduction: Outlines the code structure, compilation and packaging results, and the differences from native projects for Portal and Bundle projects.
Manage component dependencies
To simplify upgrading the mPaaS SDK baseline and managing component dependencies, first upgrade the Android Studio mPaaS plug-in to the latest version. For more information about how to update the mPaaS plug-in, see Update the mPaaS plug-in.
Add component dependencies
To use mPaaS components, add the dependencies for the components to the Portal and Bundle projects:
Adding dependencies to the Portal project ensures that they are included in your APK during packaging.
Adding dependencies to the Bundle project ensures that you can call the component's APIs in the Bundle project.
For a single Portal project, add the dependencies only to the Portal project.
If you already selected the components when you created the mPaaS project, you can still add or remove components by following the steps below.
Procedure
In Android Studio, choose mPaaS > Component-based Integration. In the integration panel that appears, click Start Configuration under Configure/Update Components.
In the component management window that appears, click the buttons to install the components you need.
For uninstalled components, the button is labeled "Not Installed". Click the button to install the component.
For installed components, the button is labeled "Installed". Click the button again to uninstall the component.
What to do next
If this is your first time using the Component Management feature in the Android Studio mPaaS plug-in to add components, you must also check or modify the following configurations.
Check the
build.gradlefile in the root directory of the Portal or Bundle project. Make sure that it contains the following dependency and the version is 2.8.0 or later:buildscript { ... dependencies { classpath 'com.android.boost.easyconfig:easyconfig:2.8.4' } }Check the
build.gradlefile in the main module of the Portal project. Make sure that it contains the following content:apply plugin: 'com.alipay.portal' portal { allSlinks true mergeAssets true } apply plugin: 'com.alipay.apollo.baseline.update' mpaascomponents{ excludeDependencies=[] }Delete old dependencies:
ImportantBack up the following content before you delete it.
For the Portal & Bundle mode, in the
build.gradlefile of the main module of the Portal project, delete the mPaaS component dependencies under the dependencies node. Do not deletempaas-baseresjar.For the single Portal project mode, in the
build.gradlefile of the main module, delete the following content:apply from: rootProject.getRootDir().getAbsolutePath() + "/mpaas_bundles.gradle" apply from: rootProject.getRootDir().getAbsolutePath() + "/mpaas_apis.gradle"Also, delete the
mpaas_bundles.gradleandmpaas_apis.gradlefiles from the project's root directory. Note that deleting thempaas_apis.gradlefile may cause the compilation to fail. You must modify the configuration in the sub-module as described below.
To call mPaaS component APIs in a sub-module:
For a Portal & Bundle mode project, add the following to the
build.gradlefile in the sub-module of the Bundle project:apply plugin: 'com.alipay.apollo.baseline.update'For a single Portal project mode, delete the following from the
build.gradlefile in the sub-module:apply from: rootProject.getRootDir().getAbsolutePath() + "/mpaas_apis.gradle"Then, add the following:
apply plugin: 'com.alipay.apollo.baseline.update'
If the old dependencies contain custom libraries, you must also add custom dependencies.
If the compilation fails due to library conflicts, see Overview.
Upgrade the baseline
In Android Studio, choose mPaaS > Component-based Integration. In the integration panel that appears, click Start Configuration under Integrate/Upgrade Baseline.
Click the version drop-down list, select a new version, and then click OK to upgrade the baseline.
Upgrade a single component
New version
In Android Studio, choose mPaaS > Component Upgrade. A list of components appears.
Check the component status and perform the upgrade. If an update notification appears in the upper-right corner, click it to update the component.

Old version
In Android Studio, choose mPaaS > Component Upgrade. A list of components appears.
Check the component status and perform the upgrade:
If the status is Latest, the component does not need to be upgraded.
Otherwise, a new version is available. You can click the status button to upgrade the component.

Add custom dependencies
If this is your first time using Component Management to manage components and you have not upgraded the SDK, add the custom library under the dependencies node in the
build.gradlefile of the main module of the Portal project. For example:bundle 'com.alipay.android.phone.mobilesdk:logging-build:2.0.2.18032216xxxx@jar' manifest 'com.alipay.android.phone.mobilesdk:logging-build:2.0.2.18032216xxxx:AndroidManifest@xml'If this is your first time using Component Management to manage components and you have upgraded the SDK, or if you have upgraded the SDK using Baseline Upgrade, your custom library may require re-customization for the new version. submit a ticket or contact the mPaaS technical support to confirm. After the library is re-customized, or after you confirm that re-customization is not required, you can add the custom dependency as described above.
Build
Click mPaaS > Build to compile the project using the Build feature of the mPaaS plug-in for Android Studio.