{"record":{"id":"041cb0edaf90f006","repo":"Tencent/tinker","slug":"libname-or-context-is-null","errorCode":null,"errorMessage":"libName or context is null!","messagePattern":"libName or context is null!","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/library/TinkerLoadLibrary.java","lineNumber":32,"sourceCode":" * limitations under the License.\n */\n\npackage com.tencent.tinker.lib.library;\n\nimport android.content.Context;\n\nimport com.tencent.tinker.entry.ApplicationLike;\nimport com.tencent.tinker.loader.TinkerRuntimeException;\n\n/**\n * Created by zhangshaowen on 17/1/5.\n * Thanks for Android Fragmentation\n */\n\npublic class TinkerLoadLibrary {\n    public static void loadArmLibrary(Context context, String libName) {\n        if (libName == null || libName.isEmpty() || context == null) {\n            throw new TinkerRuntimeException(\"libName or context is null!\");\n        }\n        System.loadLibrary(libName);\n    }\n\n    public static void loadArmLibraryWithoutTinkerInstalled(ApplicationLike appLike, String libName) {\n        if (libName == null || libName.isEmpty() || appLike == null) {\n            throw new TinkerRuntimeException(\"libName or appLike is null!\");\n        }\n        System.loadLibrary(libName);\n    }\n\n    public static void loadArmV7Library(Context context, String libName) {\n        if (libName == null || libName.isEmpty() || context == null) {\n            throw new TinkerRuntimeException(\"libName or context is null!\");\n        }\n        System.loadLibrary(libName);\n    }\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/library/TinkerLoadLibrary.java#L14-L50","documentation":"TinkerLoadLibrary.loadArmLibrary(Context, String) (no-op variant shipped in tinker-android-lib-no-op) validates its arguments before calling System.loadLibrary, throwing TinkerRuntimeException(\"libName or context is null!\") when libName is null, empty, or context is null. The no-op artifact exists so release-only Tinker code can compile in builds where Tinker is disabled; the guards still fire because they are argument checks, not patch logic.","triggerScenarios":"Calling loadArmLibrary(context, libName) with a null Context (e.g. before it is initialized) or with a null/empty library name string (typo'd constant, config key missing).","commonSituations":"Using the no-op dependency in a debug build variant while production code calls loadArmLibrary; loading a .so whose name comes from BuildConfig or a config map that is unset in that variant; calling from a component where the context field is not yet assigned.","solutions":["Pass the application context (e.g. from ApplicationLike.getApplication() or onAttachBaseContext) and a hard-coded, verified library name.","Check the source of the libName string — log it before the call to catch empty/whitespace values.","If the call is only meaningful with Tinker enabled, gate it behind Tinker.isTinkerInstalled() or your own build-variant flag."],"exampleFix":"// before\nTinkerLoadLibrary.loadArmLibrary(context, libName); // context null in this variant\n\n// after\nif (context != null && libName != null && !libName.trim().isEmpty()) {\n    TinkerLoadLibrary.loadArmLibrary(context, libName);\n} else {\n    Log.w(TAG, \"skip loadArmLibrary: context=\" + context + \" libName='\" + libName + \"'\");\n}","handlingStrategy":"validation","validationCode":"if (context != null && libName != null && !libName.trim().isEmpty()) {\n    TinkerLoadLibrary.loadArmLibrary(context, libName);\n} else {\n    Log.w(TAG, \"loadArmLibrary skipped: bad args\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the application context from a lifecycle callback, never an early-captured field","Define library names as final constants per flavor"],"tags":["android","tinker","native-library","null-check","no-op"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}