Tencent/tinker · error · TinkerRuntimeException

libName or context is null!

Error message

libName or context is null!

What it means

Thrown by TinkerApplicationHelper.loadArmV7aLibrary when libName is null/empty or the ApplicationLike is null. This helper loads lib/armeabi-v7a .so files from the patch before Tinker is installed; it needs both a concrete library name and a context to look in. The guard catches wiring mistakes instead of letting System.loadLibrary fail cryptically.

Source

Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/TinkerApplicationHelper.java:256

     *
     * @param applicationLike
     */
    public static void cleanPatch(ApplicationLike applicationLike) {
        if (applicationLike == null || applicationLike.getApplication() == null) {
            throw new TinkerRuntimeException("tinkerApplication is null");
        }
        ShareTinkerInternals.cleanPatch(applicationLike.getApplication());
    }

    /**
     * only support auto load lib/armeabi-v7a library from patch.
     * in some process, you may not want to install tinker
     * and you can load patch dex and library without install tinker!
     * }
     */
    public static void loadArmV7aLibrary(ApplicationLike applicationLike, String libName) {
        if (libName == null || libName.isEmpty() || applicationLike == null) {
            throw new TinkerRuntimeException("libName or context is null!");
        }

        if (TinkerApplicationHelper.isTinkerEnableForNativeLib(applicationLike)) {
            if (TinkerApplicationHelper.loadLibraryFromTinker(applicationLike, "lib/armeabi-v7a", libName)) {
                return;
            }

        }
        System.loadLibrary(libName);
    }


    /**
     * only support auto load lib/armeabi library from patch.
     * in some process, you may not want to install tinker
     * and you can load patch dex and library without install tinker!
     */
    public static void loadArmLibrary(ApplicationLike applicationLike, String libName) {

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Pass a non-empty libName exactly as in System.loadLibrary (no 'lib' prefix, no '.so' suffix).
  2. Inject the ApplicationLike into the class performing native loads.
  3. If the ApplicationLike may be absent (e.g. tinker disabled builds), guard and fall back to System.loadLibrary.

Example fix

// before
TinkerApplicationHelper.loadArmV7aLibrary(null, "mylib");

// after
if (appLike != null && !TextUtils.isEmpty("mylib")) {
    TinkerApplicationHelper.loadArmV7aLibrary(appLike, "mylib");
} else {
    System.loadLibrary("mylib");
}
Defensive patterns

Strategy: validation

Validate before calling

if (appLike == null || appLike.getApplication() == null || libName == null || libName.trim().isEmpty()) {
    System.loadLibrary(libName == null || libName.trim().isEmpty() ? "mylib" : libName);
    return;
}
TinkerApplicationHelper.loadArmV7aLibrary(appLike, libName);

Type guard

static boolean canLoadFromTinker(ApplicationLike like, String libName) {
    return like != null && like.getApplication() != null
        && libName != null && !libName.trim().isEmpty();
}

Prevention

When it happens

Trigger: Calling loadArmV7aLibrary(appLike, null), with an empty string, or passing a null ApplicationLike — e.g. System.loadLibrary("mylib") replaced by the tinker helper in a class where the ApplicationLike was not provided.

Common situations: Migrating native-lib loading to support patches and forgetting to inject the ApplicationLike; calling from static initializers of native-backed classes (SoLoader-style init) that run before the ApplicationLike is available.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/1d40c95ce561c544. Report an issue: GitHub.