{"record":{"id":"2db4d4b04adab366","repo":"Tencent/tinker","slug":"tinkerapplication-is-null","errorCode":null,"errorMessage":"tinkerApplication is null","messagePattern":"tinkerApplication is null","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/TinkerApplicationHelper.java","lineNumber":50,"sourceCode":"import java.util.Map;\n\n/**\n * sometimes, you may want to install tinker later, or never install tinker in some process.\n * you can use {@code TinkerApplicationHelper} API to get the tinker status!\n * Created by zhangshaowen on 16/6/28.\n */\npublic class TinkerApplicationHelper {\n    private static final String TAG = \"Tinker.TinkerApplicationHelper\";\n\n    /**\n     * they can use without Tinker is installed!\n     * same as {@code Tinker.isTinkerEnabled}\n     *\n     * @return\n     */\n    public static boolean isTinkerEnableAll(ApplicationLike applicationLike) {\n        if (applicationLike == null || applicationLike.getApplication() == null) {\n            throw new TinkerRuntimeException(\"tinkerApplication is null\");\n        }\n        int tinkerFlags = applicationLike.getTinkerFlags();\n        return ShareTinkerInternals.isTinkerEnabledAll(tinkerFlags);\n    }\n\n    /**\n     * same as {@code Tinker.isEnabledForDex}\n     *\n     * @param applicationLike\n     * @return\n     */\n    public static boolean isTinkerEnableForDex(ApplicationLike applicationLike) {\n        if (applicationLike == null || applicationLike.getApplication() == null) {\n            throw new TinkerRuntimeException(\"tinkerApplication is null\");\n        }\n        int tinkerFlags = applicationLike.getTinkerFlags();\n        return ShareTinkerInternals.isTinkerEnabledForDex(tinkerFlags);\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/TinkerApplicationHelper.java#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the ApplicationLike you received in your ApplicationLike's constructor (e.g. from TinkerApplication's delegate), not the Application.","Delay status queries until after ApplicationLike#onCreate has run so the underlying Application is attached.","If you cannot guarantee it, null-check applicationLike before calling and treat null as 'tinker disabled'."],"exampleFix":"// before\nboolean enabled = TinkerApplicationHelper.isTinkerEnableAll(null);\n\n// after\nboolean enabled = applicationLike != null && applicationLike.getApplication() != null\n    && TinkerApplicationHelper.isTinkerEnableAll(applicationLike);","handlingStrategy":"type-guard","validationCode":"if (applicationLike == null || applicationLike.getApplication() == null) {\n    // treat as tinker disabled; do not call the helper\n    return false;\n}\nreturn TinkerApplicationHelper.isTinkerEnableAll(applicationLike);","typeGuard":"static boolean isValid(ApplicationLike like) {\n    return like != null && like.getApplication() != null;\n}","tryCatchPattern":null,"preventionTips":["Pass the ApplicationLike received in your ApplicationLike subclass, never a fresh/null reference.","Query helpers only after Application onCreate so getApplication() is non-null.","Keep one well-known holder for the ApplicationLike singleton across the app."],"tags":["tinker","android","null-argument","application-lifecycle"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}