Alibaba Cloud Android Demo

repository·master·Indexed 21 days ago

https://github.com/aliyun/alicloud-android-demo

A collection of Android demonstration projects for Alibaba Cloud EMAS (Enterprise Mobile Application Studio) services. Includes implementation examples for HTTPDNS, Push Notifications, Application Performance Monitoring (APM), User Feedback, Hotfix (Sophix), and DevOps.

Tokens
4.2K
Snippets
16
Records
22
Agent score
76%

What's inside alicloud-android-demo

  1. Overview of EMAS Android Product Demos

    master

    This repository provides Android demonstration projects for various EMAS services. Use the following list to identify which demo matches your requirements:

    • HTTPDNS: Domain name resolution service based on HTTP(S) to prevent DNS hijacking and ensure stability.
      • Android Demo: httpdns_android_demo (No AppKey/AppSecret required).
    • Mobile Push (移动推送): Efficient and real-time message delivery to users.
      • Android Demo: mpush_android_demo.
    • Application Performance Monitoring (APM/应用性能监控): Comprehensive monitoring for app stability and performance.
      • Android Demo: apm_android_demo.
    • Mobile User Feedback (移动用户反馈): Tools for collecting and managing user feedback within the app.
      • Android Demo: feedback_android_demo.
    • Mobile Hotfix (移动热修复): Online hotfix service based on Sophix technology to fix bugs without waiting for a new app release.
      • Android Demo: hotfix_android_demo.
    • Mobile DevOps (移动DevOps): Cloud-based build and release services to automate the application lifecycle.
      • Android Demo: devops_android_demo.
  2. Quickstart: Set up the Mobile Hotfix Demo APP

    master

    To use the Mobile Hotfix (Sophix) Demo, follow these steps:

    1. Create an App Entity: Log in to the Mobile Hotfix Console and create an App entity to represent your application.
    2. Download the Demo: Clone the repository to your local machine. The hotfix implementation is located in the hotfix_android_demo directory.
    3. Configure Credentials: Replace the placeholder values in AndroidManifest.xml with your actual IDSECRET, APPSECRET, and RSASECRET obtained from the console.
    4. Run the Program: Build and run the project. Verify successful integration by checking the logs for the SophixManager.getInstance().initialize() output.
    git clone https://github.com/aliyun/alicloud-android-demo.git
  3. Quickstart for EMAS Android Demos

    master

    To use the EMAS (Enterprise Mobile Application Studio) Android demos, follow these steps:

    1. Clone the repository:
      git clone https://github.com/aliyun/alicloud-android-demo.git
    2. Select a product demo: Each sub-directory contains a specific EMAS product demo. Refer to the README.md within each specific product directory for detailed integration instructions.
    3. Configure credentials:
      • For HTTPDNS, no application creation is required. Follow the specific instructions in httpdns_android_demo/README.md.
      • For all other products, log in to the EMAS Console to create an application and obtain your AppKey, AppSecret, and other necessary configuration information.
      • Apply these credentials to the respective demo as instructed in their local README.md files.

    Note: The credentials provided in the demos are for demonstration purposes only. For production environments, use security best practices (like Alibaba Cloud's Security Black Box) to protect your keys.

    git clone https://github.com/aliyun/alicloud-android-demo.git
  4. Quickstart: Use the HTTPDNS Android Demo

    master

    The httpdns_android_demo project is a demonstration application that shows how to integrate the Alibaba Cloud HTTPDNS SDK. HTTPDNS uses the HTTP protocol for domain name resolution instead of the traditional UDP-based DNS, allowing you to bypass carrier Local DNS to avoid domain hijacking and inaccurate scheduling.

    To use this demo to test your own configuration:

    1. Enable the product in the Alibaba Cloud console.
    2. Add your domains to the HTTPDNS console. Changes take effect within 1 minute.
    3. Clone the repository to your local machine.
    4. Configure your Account ID in the aliyun-emas-services.json file.
    5. Run the app and enter your configured domain in the input field to test resolution.
    git clone https://github.com/aliyun/alicloud-android-demo.git
  5. Quickstart: Set up the Alibaba Cloud Mobile Push Android Demo

    master

    To use the mpush_android_demo project to test Alibaba Cloud Mobile Push integration, follow these steps:

    1. Create an App in the Console: Log in to the Mobile Push console and create an App entity to obtain your credentials.
    2. Clone the Repository: Download the demo project to your local machine.
    3. Configure Credentials: Replace the placeholder ******** in AndroidManifest.xml with your actual appKey and appSecret.
    4. Configure Package Name: Update the applicationId in your build.gradle file to match the package name of the App you created in the console.
    5. Run the App: Build and run the project. Click 注册并接收推送 (Register and Receive Push) in the app to trigger the registration process.
    git clone https://github.com/aliyun/alicloud-android-demo.git
  6. Quickstart: Integrate Mobile Feedback SDK into an Android App

    master

    To use the Alibaba Cloud Mobile Feedback SDK, follow these steps:

    1. Create an App in the Console: Log in to the Mobile Feedback console and create an App entity to obtain your credentials.
    2. Obtain Credentials: Retrieve your AppKey and AppSecret from the Mobile Feedback console.
    3. Initialize the SDK: Call FeedbackAPI.init in your application code using your specific credentials.
    4. Verify Integration: If the SDK is correctly integrated, you should be able to open the feedback interface within your app to submit feedback descriptions.
    FeedbackAPI.init(application, appkey, appSecret);
  7. Configure IDSECRET, APPSECRET, and RSASECRET

    master

    The Mobile Hotfix SDK requires three specific credentials to function. You can configure these in your AndroidManifest.xml using <meta-data> tags.

    Security Note: For better security, it is recommended to use the setSecretMetaData method to set these values programmatically instead of using plain text in AndroidManifest.xml.

    <meta-data
        android:name="com.taobao.android.hotfix.IDSECRET"
        android:value="********" />
    <meta-data
        android:name="com.taobao.android.hotfix.APPSECRET"
        android:value="********" />
    <meta-data
        android:name="com.taobao.android.hotfix.RSASECRET"
        android:value="********" />
  8. Verify Mobile Push Integration via Logcat

    master

    After running the app and clicking the registration button, verify the integration by checking Logcat for the following indicators:

    1. Registration Success: Filter by tag MPS. You should see agoo init success and a success code PUSH_00000.
    2. Cloud Channel Initialization: Filter by keyword awcn. Look for [awcn.TnetSpdySession] statusCode:200 and notifyStatus status:AUTH_SUCC.
    3. Device ID: Ensure cloudPushService.getDeviceId() returns a valid ID after successful initialization.
    // Example of successful registration log
    [MPS] I agoo init success.
    [MPS] D register agoo result 错误码:PUSH_00000, 错误:success
    MPS:AppRegister I connState=2;estimatedTime=384;response{msg: success, code: PUSH_00000}
    
    // Example of successful cloud channel (awcn) log
    [awcn.TnetSpdySession] statusCode:200
    [awcn.Session]|[seq:334786623.AWCN1_1] notifyStatus status:AUTH_SUCC
  9. Verify APM features in the Demo APP

    master

    Once the app is running, you can verify the following features by interacting with the Demo UI:

    Crash Analysis

    • Trigger crashes via buttons: Java崩溃-空指针 (NullPointer), Native崩溃-SIGSEGV, 卡顿 (Jank), or 自定义异常 (Custom Exception).
    • Trigger other errors via the 其他类型错误 page: IllegalState, ArrayOutOfBounds, TypeConversion, SIGABRT, SIGBUS, SIGILL, ANR, or OOM.
    • Note: Crashes will cause the app to exit; data is reported to the console after the app restarts.

    Performance Monitoring

    • Startup Analysis: Use 启动分析 to verify cold and hot starts (for hot start, move the app to the background and return to the foreground).
    • Page Analysis: Use 页面分析 and scroll through pages. Data is uploaded when the app is moved to the background.
    • Network Analysis: Use 网络分析 to trigger requests via OkHttp or HttpUrlConnection, or to simulate network/HTTP errors.

    Log Collection

    • Log Retrieval (日志回捞): Click to write a log, then create a retrieval task in the EMAS console.
    • Active Reporting (主动上报): Click to write and immediately report a log.
    • Note: Most data is uploaded in batches when the app moves to the background (wait 1-2 minutes for console visibility).