help-icon
icon

原生Xposed服务集成指南

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

Panduan ini ditujukan untuk native image yang diadaptasi tanpa tag Xposed. Gunakan native Xposed activation component untuk menghindari masalah risk control yang dapat disebabkan oleh library Xposed open source.

1. Lingkup

Gunakan panduan ini untuk mengintegrasikan preloading layanan Xposed atau kemampuan pendamping ke native image yang didukung FoxPhone. Sistem Android yang didukung saat ini:

  • AOSP 10
  • AOSP 12

Jangan menambahkan dependency Xposed Bridge open source lain secara bersamaan. AAR ini menggunakan namespace API yang telah diadaptasi platform; mencampur library Bridge lain dapat menyebabkan konflik class, kegagalan pemuatan, atau sinyal risk control tambahan.

2. Unduh dependensi integrasi

Unduh AAR yang disediakan platform dan pertahankan nama file xposed-bridge-debug.aar:

xposed-bridge-debug.aar 264.87 KB

  • Ukuran file: 271231 bytes (sekitar 264.87 KB)
  • SHA-256:D9DC538315E875D83357B3986CC27D1F7535BE17D9F3F6E69C2F327C9A23FC98
  • Android API minimum: 26

3. Integrasi demo Android

Langkah 1: Buat proyek Android

  1. Buat proyek Android di 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.

Membuat proyek No Activity di Android Studio

Langkah 2: Tambahkan 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')
}

Langkah 3: Konfigurasikan entry point modul

  1. Create an assets directory under app/src/main/.
  2. Buat file tanpa ekstensi xposed_init。
  3. Isi nama lengkap satu kelas entry di setiap baris. Contoh:
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.

Langkah 4: Implementasikan kelas 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.

Langkah 5: Periksa struktur proyek

Setelah konfigurasi, proyek harus berisi setidaknya file berikut:

  • 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

Struktur proyek modul Xposed native

Langkah 6: Konfigurasikan aturan obfuscation

Jika release build mengaktifkan R8 atau ProGuard, pertahankan kelas entry agar namanya tidak diubah atau dihapus:

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

Jika Anda mengubah package name kelas entry, perbarui juga xposed_init and the obfuscation rules.。

Langkah 7: Build dan verifikasi

  1. Jalankan Gradle Sync dan pastikan dependency AAR berhasil di-resolve.
  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. Pertanyaan umum

1. Modul tidak berjalan setelah instalasi

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. Antarmuka Xposed tidak ditemukan saat kompilasi

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. Paket Release terpasang, tetapi entry tidak berjalan

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

4. Muncul kelas duplikat atau konflik Bridge saat runtime

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

5. Modul memengaruhi aplikasi non-target

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

Email contact
Cookie notification iconPemberitahuan Cookie
Situs web ini menggunakan cookie untuk meningkatkan pengalaman pengguna. Untuk mempelajari lebih lanjut tentang kebijakan cookie kami atau menarik persetujuan Anda, silakan periksa Kebijakan Privasi dan Kebijakan Cookie kami.