Tencent/tinker · error · TinkerRuntimeException

tinkerApplication is null

Error message

tinkerApplication is null

What it means

Thrown by TinkerApplicationHelper.isTinkerEnableAll when the supplied ApplicationLike is null or its wrapped Application is null. These helpers are designed to be usable BEFORE Tinker is installed, so they validate the ApplicationLike directly instead of relying on an installed Tinker instance. A null applicationLike almost always means you passed the wrong object or called before it was constructed.

Source

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

import java.util.Map;

/**
 * sometimes, you may want to install tinker later, or never install tinker in some process.
 * you can use {@code TinkerApplicationHelper} API to get the tinker status!
 * Created by zhangshaowen on 16/6/28.
 */
public class TinkerApplicationHelper {
    private static final String TAG = "Tinker.TinkerApplicationHelper";

    /**
     * they can use without Tinker is installed!
     * same as {@code Tinker.isTinkerEnabled}
     *
     * @return
     */
    public static boolean isTinkerEnableAll(ApplicationLike applicationLike) {
        if (applicationLike == null || applicationLike.getApplication() == null) {
            throw new TinkerRuntimeException("tinkerApplication is null");
        }
        int tinkerFlags = applicationLike.getTinkerFlags();
        return ShareTinkerInternals.isTinkerEnabledAll(tinkerFlags);
    }

    /**
     * same as {@code Tinker.isEnabledForDex}
     *
     * @param applicationLike
     * @return
     */
    public static boolean isTinkerEnableForDex(ApplicationLike applicationLike) {
        if (applicationLike == null || applicationLike.getApplication() == null) {
            throw new TinkerRuntimeException("tinkerApplication is null");
        }
        int tinkerFlags = applicationLike.getTinkerFlags();
        return ShareTinkerInternals.isTinkerEnabledForDex(tinkerFlags);
    }

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Pass the ApplicationLike you received in your ApplicationLike's constructor (e.g. from TinkerApplication's delegate), not the Application.
  2. Delay status queries until after ApplicationLike#onCreate has run so the underlying Application is attached.
  3. If you cannot guarantee it, null-check applicationLike before calling and treat null as 'tinker disabled'.

Example fix

// before
boolean enabled = TinkerApplicationHelper.isTinkerEnableAll(null);

// after
boolean enabled = applicationLike != null && applicationLike.getApplication() != null
    && TinkerApplicationHelper.isTinkerEnableAll(applicationLike);
Defensive patterns

Strategy: type-guard

Validate before calling

if (applicationLike == null || applicationLike.getApplication() == null) {
    // treat as tinker disabled; do not call the helper
    return false;
}
return TinkerApplicationHelper.isTinkerEnableAll(applicationLike);

Type guard

static boolean isValid(ApplicationLike like) {
    return like != null && like.getApplication() != null;
}

Prevention

When it happens

Trigger: Calling TinkerApplicationHelper.isTinkerEnableAll(null) or passing an ApplicationLike whose getApplication() returns null — e.g. calling it with a not-yet-initialized ApplicationLike field, or passing the Application instead of the ApplicationLike.

Common situations: Utility/feedback code (crash reporters, update managers) querying tinker status from a class that never received the ApplicationLike, or calling during attachBaseContext before the ApplicationLike delegate was created.

Related errors


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