[{"data":1,"prerenderedAt":490},["ShallowReactive",2],{"content-query-6s1YIa1IyT":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":484,"_id":485,"_source":486,"_file":487,"_stem":488,"_extension":489},"\u002Fdocs\u002Fandroid-sdk","docs",false,"","Android 接入指南","在 Android 应用中集成 XXinstall 归因 SDK。",{"type":11,"children":12,"toc":478},"root",[13,21,27,32,39,44,51,91,130,138,348,353,472],{"type":14,"tag":15,"props":16,"children":18},"element","h2",{"id":17},"概述",[19],{"type":20,"value":17},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25],{"type":20,"value":26},"Android 归因 SDK 核心逻辑以 AAR（R8 混淆）二进制分发，支持 React Native (Expo)、Flutter 和纯原生 Kotlin\u002FJava 三种接入方式。归因完成后自动上报设备画像（去重\u002F防刷）。",{"type":14,"tag":15,"props":28,"children":30},{"id":29},"接入方式",[31],{"type":20,"value":29},{"type":14,"tag":33,"props":34,"children":36},"h3",{"id":35},"纯原生-kotlinjava-项目",[37],{"type":20,"value":38},"纯原生 Kotlin\u002FJava 项目",{"type":14,"tag":22,"props":40,"children":41},{},[42],{"type":20,"value":43},"如果你的 Android 项目不使用 React Native，可以直接集成 AAR：",{"type":14,"tag":45,"props":46,"children":48},"h4",{"id":47},"集成-aar",[49],{"type":20,"value":50},"集成 AAR",{"type":14,"tag":52,"props":53,"children":54},"ol",{},[55,78],{"type":14,"tag":56,"props":57,"children":58},"li",{},[59,61,68,70,76],{"type":20,"value":60},"将 ",{"type":14,"tag":62,"props":63,"children":65},"code",{"className":64},[],[66],{"type":20,"value":67},"xxinstall-core.aar",{"type":20,"value":69}," 放入 ",{"type":14,"tag":62,"props":71,"children":73},{"className":72},[],[74],{"type":20,"value":75},"app\u002Flibs\u002F",{"type":20,"value":77}," 目录",{"type":14,"tag":56,"props":79,"children":80},{},[81,83,89],{"type":20,"value":82},"在 ",{"type":14,"tag":62,"props":84,"children":86},{"className":85},[],[87],{"type":20,"value":88},"build.gradle",{"type":20,"value":90}," 中添加依赖：",{"type":14,"tag":92,"props":93,"children":97},"pre",{"className":94,"code":95,"language":96,"meta":7,"style":7},"language-groovy shiki shiki-themes github-dark","dependencies {\n    implementation fileTree(dir: 'libs', include: ['*.aar'])\n}\n","groovy",[98],{"type":14,"tag":62,"props":99,"children":100},{"__ignoreMap":7},[101,112,121],{"type":14,"tag":102,"props":103,"children":106},"span",{"class":104,"line":105},"line",1,[107],{"type":14,"tag":102,"props":108,"children":109},{},[110],{"type":20,"value":111},"dependencies {\n",{"type":14,"tag":102,"props":113,"children":115},{"class":104,"line":114},2,[116],{"type":14,"tag":102,"props":117,"children":118},{},[119],{"type":20,"value":120},"    implementation fileTree(dir: 'libs', include: ['*.aar'])\n",{"type":14,"tag":102,"props":122,"children":124},{"class":104,"line":123},3,[125],{"type":14,"tag":102,"props":126,"children":127},{},[128],{"type":20,"value":129},"}\n",{"type":14,"tag":52,"props":131,"children":132},{"start":123},[133],{"type":14,"tag":56,"props":134,"children":135},{},[136],{"type":20,"value":137},"调用 SDK：",{"type":14,"tag":92,"props":139,"children":143},{"className":140,"code":141,"language":142,"meta":7,"style":7},"language-kotlin shiki shiki-themes github-dark","import com.xxinstall.sdk.XXinstall\nimport com.xxinstall.sdk.XXinstallConfig\n\n\u002F\u002F 设置 API 地址\nXXinstall.setHost(\"https:\u002F\u002Fyour-api-domain.com\")\n\n\u002F\u002F 初始化并获取归因结果\nval config = XXinstallConfig(\n    appKey = \"YOUR_APP_KEY\",\n    appSecret = \"YOUR_APP_SECRET\",\n    debug = true,\n)\n\nXXinstall.init(context, config) { result ->\n    result.fold(\n        onSuccess = { attr ->\n            Log.d(\"XXinstall\", \"归因: inviteCode=${attr.inviteCode}, channel=${attr.channel}\")\n        },\n        onFailure = { err ->\n            Log.e(\"XXinstall\", \"归因失败: ${err.message}\")\n        },\n    )\n}\n","kotlin",[144],{"type":14,"tag":62,"props":145,"children":146},{"__ignoreMap":7},[147,155,163,172,181,190,198,207,216,225,234,243,252,260,269,278,287,296,305,314,323,331,340],{"type":14,"tag":102,"props":148,"children":149},{"class":104,"line":105},[150],{"type":14,"tag":102,"props":151,"children":152},{},[153],{"type":20,"value":154},"import com.xxinstall.sdk.XXinstall\n",{"type":14,"tag":102,"props":156,"children":157},{"class":104,"line":114},[158],{"type":14,"tag":102,"props":159,"children":160},{},[161],{"type":20,"value":162},"import com.xxinstall.sdk.XXinstallConfig\n",{"type":14,"tag":102,"props":164,"children":165},{"class":104,"line":123},[166],{"type":14,"tag":102,"props":167,"children":169},{"emptyLinePlaceholder":168},true,[170],{"type":20,"value":171},"\n",{"type":14,"tag":102,"props":173,"children":175},{"class":104,"line":174},4,[176],{"type":14,"tag":102,"props":177,"children":178},{},[179],{"type":20,"value":180},"\u002F\u002F 设置 API 地址\n",{"type":14,"tag":102,"props":182,"children":184},{"class":104,"line":183},5,[185],{"type":14,"tag":102,"props":186,"children":187},{},[188],{"type":20,"value":189},"XXinstall.setHost(\"https:\u002F\u002Fyour-api-domain.com\")\n",{"type":14,"tag":102,"props":191,"children":193},{"class":104,"line":192},6,[194],{"type":14,"tag":102,"props":195,"children":196},{"emptyLinePlaceholder":168},[197],{"type":20,"value":171},{"type":14,"tag":102,"props":199,"children":201},{"class":104,"line":200},7,[202],{"type":14,"tag":102,"props":203,"children":204},{},[205],{"type":20,"value":206},"\u002F\u002F 初始化并获取归因结果\n",{"type":14,"tag":102,"props":208,"children":210},{"class":104,"line":209},8,[211],{"type":14,"tag":102,"props":212,"children":213},{},[214],{"type":20,"value":215},"val config = XXinstallConfig(\n",{"type":14,"tag":102,"props":217,"children":219},{"class":104,"line":218},9,[220],{"type":14,"tag":102,"props":221,"children":222},{},[223],{"type":20,"value":224},"    appKey = \"YOUR_APP_KEY\",\n",{"type":14,"tag":102,"props":226,"children":228},{"class":104,"line":227},10,[229],{"type":14,"tag":102,"props":230,"children":231},{},[232],{"type":20,"value":233},"    appSecret = \"YOUR_APP_SECRET\",\n",{"type":14,"tag":102,"props":235,"children":237},{"class":104,"line":236},11,[238],{"type":14,"tag":102,"props":239,"children":240},{},[241],{"type":20,"value":242},"    debug = true,\n",{"type":14,"tag":102,"props":244,"children":246},{"class":104,"line":245},12,[247],{"type":14,"tag":102,"props":248,"children":249},{},[250],{"type":20,"value":251},")\n",{"type":14,"tag":102,"props":253,"children":255},{"class":104,"line":254},13,[256],{"type":14,"tag":102,"props":257,"children":258},{"emptyLinePlaceholder":168},[259],{"type":20,"value":171},{"type":14,"tag":102,"props":261,"children":263},{"class":104,"line":262},14,[264],{"type":14,"tag":102,"props":265,"children":266},{},[267],{"type":20,"value":268},"XXinstall.init(context, config) { result ->\n",{"type":14,"tag":102,"props":270,"children":272},{"class":104,"line":271},15,[273],{"type":14,"tag":102,"props":274,"children":275},{},[276],{"type":20,"value":277},"    result.fold(\n",{"type":14,"tag":102,"props":279,"children":281},{"class":104,"line":280},16,[282],{"type":14,"tag":102,"props":283,"children":284},{},[285],{"type":20,"value":286},"        onSuccess = { attr ->\n",{"type":14,"tag":102,"props":288,"children":290},{"class":104,"line":289},17,[291],{"type":14,"tag":102,"props":292,"children":293},{},[294],{"type":20,"value":295},"            Log.d(\"XXinstall\", \"归因: inviteCode=${attr.inviteCode}, channel=${attr.channel}\")\n",{"type":14,"tag":102,"props":297,"children":299},{"class":104,"line":298},18,[300],{"type":14,"tag":102,"props":301,"children":302},{},[303],{"type":20,"value":304},"        },\n",{"type":14,"tag":102,"props":306,"children":308},{"class":104,"line":307},19,[309],{"type":14,"tag":102,"props":310,"children":311},{},[312],{"type":20,"value":313},"        onFailure = { err ->\n",{"type":14,"tag":102,"props":315,"children":317},{"class":104,"line":316},20,[318],{"type":14,"tag":102,"props":319,"children":320},{},[321],{"type":20,"value":322},"            Log.e(\"XXinstall\", \"归因失败: ${err.message}\")\n",{"type":14,"tag":102,"props":324,"children":326},{"class":104,"line":325},21,[327],{"type":14,"tag":102,"props":328,"children":329},{},[330],{"type":20,"value":304},{"type":14,"tag":102,"props":332,"children":334},{"class":104,"line":333},22,[335],{"type":14,"tag":102,"props":336,"children":337},{},[338],{"type":20,"value":339},"    )\n",{"type":14,"tag":102,"props":341,"children":343},{"class":104,"line":342},23,[344],{"type":14,"tag":102,"props":345,"children":346},{},[347],{"type":20,"value":129},{"type":14,"tag":45,"props":349,"children":351},{"id":350},"可选参数",[352],{"type":20,"value":350},{"type":14,"tag":354,"props":355,"children":356},"table",{},[357,381],{"type":14,"tag":358,"props":359,"children":360},"thead",{},[361],{"type":14,"tag":362,"props":363,"children":364},"tr",{},[365,371,376],{"type":14,"tag":366,"props":367,"children":368},"th",{},[369],{"type":20,"value":370},"参数",{"type":14,"tag":366,"props":372,"children":373},{},[374],{"type":20,"value":375},"类型",{"type":14,"tag":366,"props":377,"children":378},{},[379],{"type":20,"value":380},"说明",{"type":14,"tag":382,"props":383,"children":384},"tbody",{},[385,408,429,450],{"type":14,"tag":362,"props":386,"children":387},{},[388,398,403],{"type":14,"tag":389,"props":390,"children":391},"td",{},[392],{"type":14,"tag":62,"props":393,"children":395},{"className":394},[],[396],{"type":20,"value":397},"skipCache",{"type":14,"tag":389,"props":399,"children":400},{},[401],{"type":20,"value":402},"Boolean",{"type":14,"tag":389,"props":404,"children":405},{},[406],{"type":20,"value":407},"跳过缓存，强制重新归因（默认 false）",{"type":14,"tag":362,"props":409,"children":410},{},[411,420,424],{"type":14,"tag":389,"props":412,"children":413},{},[414],{"type":14,"tag":62,"props":415,"children":417},{"className":416},[],[418],{"type":20,"value":419},"skipClipboard",{"type":14,"tag":389,"props":421,"children":422},{},[423],{"type":20,"value":402},{"type":14,"tag":389,"props":425,"children":426},{},[427],{"type":20,"value":428},"跳过剪贴板读取（默认 false）",{"type":14,"tag":362,"props":430,"children":431},{},[432,441,445],{"type":14,"tag":389,"props":433,"children":434},{},[435],{"type":14,"tag":62,"props":436,"children":438},{"className":437},[],[439],{"type":20,"value":440},"skipWebView",{"type":14,"tag":389,"props":442,"children":443},{},[444],{"type":20,"value":402},{"type":14,"tag":389,"props":446,"children":447},{},[448],{"type":20,"value":449},"跳过内置 WebView 指纹采集（默认 false）",{"type":14,"tag":362,"props":451,"children":452},{},[453,462,467],{"type":14,"tag":389,"props":454,"children":455},{},[456],{"type":14,"tag":62,"props":457,"children":459},{"className":458},[],[460],{"type":20,"value":461},"webViewFingerprint",{"type":14,"tag":389,"props":463,"children":464},{},[465],{"type":20,"value":466},"Map?",{"type":14,"tag":389,"props":468,"children":469},{},[470],{"type":20,"value":471},"外部传入 WebView 指纹（用于自定义采集场景）",{"type":14,"tag":473,"props":474,"children":475},"style",{},[476],{"type":20,"value":477},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":114,"depth":114,"links":479},[480,481],{"id":17,"depth":114,"text":17},{"id":29,"depth":114,"text":29,"children":482},[483],{"id":35,"depth":123,"text":38},"markdown","content:docs:android-sdk.md","content","docs\u002Fandroid-sdk.md","docs\u002Fandroid-sdk","md",1784877317611]