{"record":{"id":"ef542c0a0efec30d","repo":"Tencent/tinker","slug":"libname-or-applike-is-null","errorCode":null,"errorMessage":"libName or appLike is null!","messagePattern":"libName or appLike 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":39,"sourceCode":"import 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\n    public static void loadArmV7LibraryWithoutTinkerInstalled(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","sourceCodeStart":21,"sourceCodeEnd":57,"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#L21-L57","documentation":"TinkerLoadLibrary.loadArmLibraryWithoutTinkerInstalled(ApplicationLike, String) validates its arguments and throws TinkerRuntimeException(\"libName or appLike is null!\") when libName is null/empty or the ApplicationLike wrapper is null. The '*WithoutTinkerInstalled' variants are meant for loading native libraries through Tinker's ABI-selection logic even when Tinker patching itself is not installed, so the only precondition checked is argument sanity.","triggerScenarios":"Calling loadArmLibraryWithoutTinkerInstalled(appLike, libName) with a null ApplicationLike (application not wrapped / passed too early) or a null/empty libName.","commonSituations":"Migrating an app to Tinker where ApplicationLike is created in attachBaseContext but the library load runs from a static initializer or another class that captures it too early; referencing a library name constant that only exists in one product flavor.","solutions":["Create/obtain the ApplicationLike first (typically app = ApplicationLike(this) inside your Application) and pass it to the call.","Verify the libName constant is non-empty in every build variant (Log it).","Move the call to a lifecycle point where both arguments are guaranteed initialized, e.g. Application.onCreate."],"exampleFix":"// before\nTinkerLoadLibrary.loadArmLibraryWithoutTinkerInstalled(appLike, \"native-lib\"); // appLike still null\n\n// after\n@Override\npublic void onCreate() {\n    super.onCreate();\n    appLike = new ApplicationLike(this);\n    TinkerLoadLibrary.loadArmLibraryWithoutTinkerInstalled(appLike, \"native-lib\");\n}","handlingStrategy":"validation","validationCode":"if (appLike != null && libName != null && !libName.trim().isEmpty()) {\n    TinkerLoadLibrary.loadArmLibraryWithoutTinkerInstalled(appLike, libName);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct ApplicationLike in attachBaseContext before any load call","Keep native loads in Application.onCreate where dependencies are initialized"],"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"}