help-icon
icon

原生Xposed服务集成指南

helpDetails-time-icon2026-09-23T15:37:56+08:00

Hướng dẫn này dành cho native image được điều chỉnh không có thẻ Xposed. Hãy dùng native Xposed activation component để tránh các vấn đề kiểm soát rủi ro do thư viện Xposed mã nguồn mở gây ra.

1. Phạm vi áp dụng

Hướng dẫn này giúp tích hợp việc preload dịch vụ Xposed hoặc các tính năng đi kèm vào native image được FoxPhone hỗ trợ. Các hệ thống Android hiện được hỗ trợ:

  • AOSP 10
  • AOSP 12

Không đồng thời thêm dependency Xposed Bridge mã nguồn mở khác. AAR này dùng namespace API đã được nền tảng điều chỉnh; trộn thêm thư viện Bridge khác có thể gây xung đột class, lỗi tải hoặc tạo thêm tín hiệu kiểm soát rủi ro.

2. Tải xuống dependency tích hợp

Tải xuống AAR do nền tảng cung cấp và giữ tên tệp là xposed-bridge-debug.aar:

xposed-bridge-debug.aar 264.87 KB

  • Kích thước tệp: 271231 bytes (khoảng 264.87 KB)
  • SHA-256:D9DC538315E875D83357B3986CC27D1F7535BE17D9F3F6E69C2F327C9A23FC98
  • Android API tối thiểu: 26

3. Tích hợp demo Android

Bước 1: Tạo dự án Android

  1. Tạo một dự án Android trong Android Studio.
  2. Choose the No Activity template to avoid generating unrelated screen code.
  3. The example can use Java; when using Kotlin, implement the entry class with the same interfaces.

Tạo dự án No Activity trong Android Studio

Bước 2: Thêm AAR

  1. Create a libs directory under the App module.
  2. Place xposed-bridge-debug.aar in app/libs/.
  3. Reference it with compileOnly in app/build.gradle.kts so the Bridge implementation is not packaged into the APK again.
dependencies {
    compileOnly(files("libs/xposed-bridge-debug.aar"))
}

For projects using the Groovy DSL, configure it in app/build.gradle:

dependencies {
    compileOnly files('libs/xposed-bridge-debug.aar')
}

Bước 3: Cấu hình điểm vào module

  1. Create an assets directory under app/src/main/.
  2. Tạo tệp không có phần mở rộng xposed_init。
  3. Nhập tên đầy đủ của một lớp entry trên mỗi dòng. Ví dụ:
com.example.myapplication.Main

The package and class name in xposed_init must exactly match the source code; otherwise the native component cannot find the entry class.

Bước 4: Triển khai lớp entry

The API package in the AAR is de.robv.android.examed, not the de.robv.android.xposed package commonly used by open-source Xposed libraries. Entry class example:

package com.example.myapplication;

import de.robv.android.examed.IXposedHookLoadPackage;
import de.robv.android.examed.XposedBridge;
import de.robv.android.examed.callbacks.XC_LoadPackage;

public class Main implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam)
            throws Throwable {
        // 必须先限制目标包,避免在所有应用进程中执行初始化逻辑。
        if (!"com.example.target".equals(loadPackageParam.packageName)) {
            return;
        }

        XposedBridge.log("Native Xposed module loaded: "
                + loadPackageParam.packageName);

        // 在此处实现经过授权的服务预启或伴随逻辑。
    }
}

Replace com.example.target with the actual target application package, and keep business logic limited to authorized applications and scenarios.

Bước 5: Kiểm tra cấu trúc dự án

Sau khi cấu hình, dự án phải có ít nhất các tệp sau:

  • app/libs/xposed-bridge-debug.aar
  • app/src/main/assets/xposed_init
  • app/src/main/java/.../Main.java or the corresponding Kotlin file
  • app/src/main/AndroidManifest.xml
  • app/build.gradle.kts or app/build.gradle

Cấu trúc dự án module Xposed native

Bước 6: Cấu hình quy tắc làm rối mã

Nếu bản build release bật R8 hoặc ProGuard, hãy giữ lại lớp entry để tên lớp không bị đổi hoặc xóa:

-keep class com.example.myapplication.Main { *; }

Nếu đổi package của lớp entry, hãy cập nhật cả xposed_init and the obfuscation rules.。

Bước 7: Build và xác minh

  1. Chạy Gradle Sync và xác nhận dependency AAR được phân giải chính xác.
  2. Build the APK and confirm that it contains assets/xposed_init.
  3. Install the APK on a supported native image instance.
  4. Enable the module through the FoxPhone native Xposed activation component.
  5. Launch the target application, check the logs for entry-class output, and verify that the business logic runs only in the target package.

4. Câu hỏi thường gặp

1. Module không chạy sau khi cài đặt

Confirm that the instance uses a supported AOSP 10 or AOSP 12 native image, that the module is activated by the native component, and that the fully qualified class name in xposed_init is correct.

2. Không tìm thấy interface Xposed khi biên dịch

Check that the AAR is in app/libs/, verify the path in the Gradle file, and confirm that the de.robv.android.examed namespace is imported.

3. Gói Release cài đặt bình thường nhưng entry không chạy

Check whether R8 or ProGuard changed or removed the entry class, and verify that the obfuscation rules match xposed_init.

4. Xuất hiện class trùng hoặc xung đột Bridge khi chạy

Remove other Xposed Bridge dependencies and confirm that the platform AAR is added with compileOnly and is not packaged into the APK twice.

5. Module ảnh hưởng đến ứng dụng không phải mục tiêu

Filter by packageName at the very start of the entry method and return immediately for non-target processes.

Email contact
Cookie notification iconThông báo Cookie
Trang web này sử dụng cookie để cải thiện trải nghiệm người dùng. Để tìm hiểu thêm về chính sách cookie của chúng tôi hoặc rút lại sự đồng ý, vui lòng kiểm tra Chính sách bảo mật và Chính sách Cookie của chúng tôi.