友盟 U-APP 统计 SDK 集成

v1.0.0

帮助用户在 Android 项目中快速集成友盟 U-APP 统计 SDK。包括自动配置依赖、权限、初始化代码、混淆规则等。触发:用户提到'友盟'、'umeng'、'U-APP'、'统计 SDK'、'集成友盟'、'移动统计'、'应用埋点'等关键词。

1· 182·0 current·0 all-time
byUmeng+@squall0925

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for squall0925/umeng-uapp-integration.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "友盟 U-APP 统计 SDK 集成" (squall0925/umeng-uapp-integration) from ClawHub.
Skill page: https://clawhub.ai/squall0925/umeng-uapp-integration
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install umeng-uapp-integration

ClawHub CLI

Package manager switcher

npx clawhub@latest install umeng-uapp-integration
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description match the instructions: the skill only describes adding Maven repos, Gradle dependencies, AndroidManifest permissions, Application initialization, ProGuard rules and verification steps — all directly relevant to integrating the Umeng SDK. The declared required files (build.gradle/build.gradle.kts/AndroidManifest.xml) are appropriate.
Instruction Scope
SKILL.md stays on-topic: it instructs code and manifest edits needed for SDK integration, includes privacy/consent guidance, and references official URLs. It does recommend adding READ_PHONE_STATE and other permissions that enable collection of device identifiers — this is expected for analytics but has privacy implications (the doc itself notes consent requirements). The skill does not instruct reading or exfiltrating unrelated system files or secrets.
Install Mechanism
Instruction-only skill with no install spec and no code to download or execute. No archives or external installers are referenced.
Credentials
No environment variables, credentials, or config paths are requested. The permissions and dependencies listed are proportional to an analytics SDK integration.
Persistence & Privilege
always:false and normal user-invocable behavior. The skill is instruction-only and does not request persistent system presence or modify other skills or global agent settings.
Assessment
This skill appears to be what it says — a step-by-step guide to integrate Umeng U-APP. Before using it, consider: (1) the instructions include sensitive Android permissions (e.g., READ_PHONE_STATE) that enable collection of device identifiers — only request them if strictly necessary and ensure you obtain user consent as the guide recommends; (2) follow local privacy/Play Store rules (Google Play restricts some identifier collection); (3) do not hardcode AppKey or secrets in public repos — retrieve from your Umeng console and keep them private; (4) verify the SDK versions and Maven repository URLs are up-to-date; (5) test in staging and disable debug logging in production; (6) the skill metadata indicates it will look for your project files (build.gradle, AndroidManifest.xml) — only allow the agent to read project files you are comfortable sharing. If you need stricter guarantees, review the code snippets yourself rather than allowing any automated edits.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

📊 Clawdis
latestvk9771esznez4rf8j7s95p0ksf9833dy5
182downloads
1stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

友盟 U-APP 统计 SDK 集成技能

何时使用

使用此技能当:

  • 用户需要在 Android 项目中集成友盟统计 SDK
  • 用户提到"友盟"、"umeng"、"U-APP"、"统计 SDK"
  • 用户需要配置移动应用数据埋点
  • 用户需要添加应用分析功能
  • 用户需要配置 SDK 初始化代码

不使用此技能当:

  • iOS 项目集成 → 使用 iOS 集成文档
  • HarmonyOS 项目 → 使用 HarmonyOS 集成文档
  • 网站统计 → 使用 U-Web SDK
  • 小程序统计 → 使用 U-Mini SDK
  • 消息推送功能 → 使用 U-Push SDK

集成流程

集成流程

1. 添加 Maven 仓库(项目级 build.gradle)

在项目根目录的 build.gradlebuild.gradle.kts 中添加:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
}

2. 添加 SDK 依赖(应用级 build.gradle)

app/build.gradleapp/build.gradle.kts 的 dependencies 块中添加:

dependencies {
    // 友盟统计 SDK - 必选
    implementation 'com.umeng.umsdk:common:9.6.6'
    implementation 'com.umeng.umsdk:asms:1.6.4'
    
    // 高级运营分析功能依赖库 - 可选(使用卸载分析、反作弊时必选)
    implementation 'com.umeng.umsdk:uyumao:1.1.2'
    
    // ABTest 功能 - 可选
    implementation 'com.umeng.umsdk:abtest:1.0.0'
}

3. 添加权限(AndroidManifest.xml)

AndroidManifest.xml<manifest> 标签内添加:

<!-- 必选权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<!-- 可选权限(用于反作弊和地域分布) -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

4. 创建 Application 类并初始化 SDK

创建或修改 Application 类:

package com.your.package

import android.app.Application
import com.umeng.analytics.MobclickSdk
import com.umeng.commonsdk.UMGlobals

class YourApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        
        // 合规初始化:预初始化(不会采集数据)
        MobclickSdk.preInit(this, "YOUR_APP_KEY", "default")
    }
    
    // 在用户同意隐私政策后调用正式初始化
    fun initUmengAfterPrivacyAgreed() {
        MobclickSdk.init(this, "YOUR_APP_KEY")
        MobclickSdk.setChannel("default")
        
        // 调试模式(发布前请关闭)
        UMGlobals.setDebugMode(true)
    }
}

AndroidManifest.xml 中注册 Application:

<application
    android:name=".YourApplication"
    ... >
</application>

5. 合规初始化流程

重要:根据工信部要求,必须在用户同意隐私政策后再初始化 SDK:

// 在 Application.onCreate() 中 - 预初始化(不采集数据)
override fun onCreate() {
    super.onCreate()
    MobclickSdk.preInit(this, "YOUR_APP_KEY", "channel")
}

// 在用户同意隐私政策后 - 正式初始化
fun onPrivacyPolicyAgreed() {
    MobclickSdk.init(this, "YOUR_APP_KEY")
    MobclickSdk.setChannel("channel")
}

6. 混淆配置(proguard-rules.pro)

如果应用使用混淆,添加以下规则:

# 友盟 SDK
-keep class com.umeng.** { *; }
-keep class com.ut.** { *; }
-keep class org.android.** { *; }
-keep class org.agoo.** { *; }
-keep class anet.channel.** { *; }
-keep class anetwork.channel.** { *; }
-keep class com.ta.** { *; }
-keep class com.ut.device.** { *; }
-keep class org.json.** { *; }
-keep class com.uyumao.** { *; }

# 保留 R 文件
-keep public class com.your.package.R$* {
    public static final int *;
}

7. 埋点验证配置(可选)

AndroidManifest.xml 中添加 scheme 用于测试埋点:

<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
    <!-- 埋点验证 scheme -->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="um.YOUR_APP_KEY" />
    </intent-filter>
</activity>

常用 API 示例

页面统计(Activity)

override fun onResume() {
    super.onResume()
    MobclickSdk.onPageStart("PageName")
    MobclickSdk.onResume(this)
}

override fun onPause() {
    super.onPause()
    MobclickSdk.onPageEnd("PageName")
    MobclickSdk.onPause(this)
}

页面统计(Compose)

// 在 Compose 中手动统计
MobclickSdk.onPageStart("HomePage")
// ... 页面内容
MobclickSdk.onPageEnd("HomePage")

自定义事件统计

// 简单事件
MobclickSdk.onEvent(context, "button_click")

// 带参数的事件
val attributes = mapOf(
    "button_id" to "submit",
    "page" to "home",
    "user_level" to "vip"
)
MobclickSdk.onEvent(context, "button_click", attributes)

// 带数值的事件(用于统计金额、时长等)
MobclickSdk.onEvent(context, "purchase", mapOf("item_id" to "123"), 99.0)

用户标识

// 设置用户 ID(登录后调用)
MobclickSdk.setUserId("user_12345")

// 清除用户 ID(登出时调用)
MobclickSdk.clearUserId()

隐私政策条款参考

在隐私政策中需要包含以下说明:

我们接入了友盟+SDK,友盟+SDK需要收集您的设备信息(IMEI/MAC/Android ID/OAID/IDFA/OpenUDID/GUID/IP 地址/SIM 卡 IMSI 信息等)及粗略位置(可选),
用于统计分析服务,以帮助您了解应用使用情况。
友盟+隐私政策链接:https://www.umeng.com/page/policy

验证集成

  1. 构建并运行应用
  2. 在 Logcat 中搜索 "umeng" 或 "mob" 关键字
  3. 查看是否有初始化成功日志
  4. 登录友盟后台,等待约 15 分钟后查看数据

常见问题

1. 数据不显示?

  • 检查 AppKey 是否正确
  • 确认包名与友盟后台配置一致
  • 等待数据延迟(约 15 分钟)
  • 检查网络权限

2. 初始化失败?

  • 确认在 Application 中初始化
  • 检查是否在用户同意隐私政策后调用
  • 查看 Logcat 错误日志

3. 混淆后 SDK 失效?

  • 确保添加了完整的混淆规则
  • 检查 R 文件是否被保留

参考资料

注意事项

  1. 合规第一:必须在用户同意隐私政策后才能正式初始化 SDK
  2. 包名一致:友盟后台配置的包名必须与应用的 applicationId 一致
  3. 数据延迟:统计数据通常有 15 分钟左右的延迟
  4. 发布前关闭调试:发布前将 setDebugMode(false)
  5. 高级功能:使用卸载分析、反作弊等功能需要集成 uyumao 库并配置混淆

Comments

Loading comments...