English | 中文
A Flutter Android plugin that bridges Android_CN_OAID to obtain OAID (Open Anonymous Device Identifier), AAID, and other device identifiers from mainstream Chinese Android manufacturers.
Android only. Calling any method on other platforms throws
UnsupportedError.
- Features
- Supported Manufacturers
- Installation
- Usage
- API Reference
- Error Handling
- Privacy Compliance Notes
- Get OAID / AAID asynchronously (supports mainstream Chinese manufacturers)
- Get AndroidID, PseudoID, GUID as fallback identifiers
- Privacy-compliant initialization — call
register()only after user consent - Structured error handling via
OaidException
| Manufacturer | System / Framework |
|---|---|
| Huawei | HMS Core 2.6.2+, Google Play Service 4.0+ |
| Honor | Magic UI 4/5/6, MagicOS 7.0+, Google Play Service 4.0+ |
| Xiaomi / Redmi / BlackShark | MIUI 10.2+, Google Play Service 4.0+ |
| VIVO / iQOO | Funtouch OS 9+, OriginOS 1.0+, Google Play Service 4.0+ |
| OPPO / Realme | ColorOS 7.0+, Google Play Service 4.0+ |
| Samsung | Android 10+, Google Play Service 4.0+ |
| Lenovo | ZUI 11.4+, Google Play Service 4.0+ |
| ASUS | Android 10+, Google Play Service 4.0+ |
| Meizu | Android 10+, Google Play Service 4.0+ |
| OnePlus | Android 10+, Google Play Service 4.0+ |
| Nubia | Android 10+, Google Play Service 4.0+ |
| Coolpad | CoolOS, Google Play Service 4.0+ |
| Others (ZTE, HTC, Motorola…) | Google Play Service 4.0+ |
Add to your pubspec.yaml:
dependencies:
android_cn_oaid: ^0.0.1Call register() after the user has agreed to your privacy policy. This pre-initializes the OAID service.
import 'package:android_cn_oaid/android_cn_oaid.dart';
final plugin = AndroidCnOaid();
// Call this after user agrees to privacy policy
await plugin.register();final supported = await plugin.isSupported();
if (!supported) {
// Device does not support OAID or AAID
}try {
// Auto-selects the best available method
final oaid = await plugin.getOAID();
print('OAID: $oaid'); // null if not supported
// Or use manufacturer-specific interface
final mfrOaid = await plugin.getOAIDByManufacturer();
} on OaidException catch (e) {
print('Error [${e.code}]: ${e.message}');
}final androidId = await plugin.getAndroidID(); // String? — may be null
final pseudoId = await plugin.getPseudoID(); // String — never null, may repeat
final guid = await plugin.getGUID(); // String — never null, randomfinal manufacturers = await plugin.getSupportedManufacturers();
print(manufacturers); // ['Huawei', 'Honor', 'Xiaomi', ...]| Method | Return Type | Description |
|---|---|---|
register() |
Future<void> |
Pre-initialize OAID service. Call after privacy policy consent. |
isSupported() |
Future<bool> |
Check if device supports OAID or AAID. |
getOAID() |
Future<String?> |
Get OAID or AAID. Returns null if unsupported. |
getOAIDByManufacturer() |
Future<String?> |
Get ad identifier via manufacturer-specific interface. |
getAndroidID() |
Future<String?> |
Get Android ID. May return null. |
getPseudoID() |
Future<String> |
Get PseudoID (hardware-based, never null, may repeat). |
getGUID() |
Future<String> |
Get GUID (randomly generated, never null). |
getSupportedManufacturers() |
Future<List<String>> |
Get list of supported manufacturer names. |
All methods may throw OaidException when the native layer encounters an error:
try {
final oaid = await plugin.getOAID();
} on OaidException catch (e) {
switch (e.code) {
case 'permission_denied':
// SecurityException on the Android side
break;
case 'oaid_error':
// General error during OAID retrieval
break;
}
print('${e.code}: ${e.message}');
} on UnsupportedError catch (e) {
// Called on a non-Android platform
print(e.message);
}Error codes:
| Code | Cause |
|---|---|
oaid_error |
General exception during OAID/AAID retrieval |
permission_denied |
SecurityException thrown by the Android system |
Per Chinese app compliance requirements:
- Do not call
register()before the user agrees to your privacy policy. - Call all identifier methods after
register(). - Disclose device identifier usage in your app's privacy policy.