{"record":{"id":"ddb8e4cdd0f26f19","repo":"amitshekhariitbhu/Android-Debug-Database","slug":"debugdbinitprovider-providerinfo-cannot-be-null","errorCode":null,"errorMessage":"DebugDBInitProvider ProviderInfo cannot be null.","messagePattern":"DebugDBInitProvider ProviderInfo cannot be null\\.","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java","lineNumber":76,"sourceCode":"    @Override\n    public Uri insert(Uri uri, ContentValues values) {\n        return null;\n    }\n\n    @Override\n    public int delete(Uri uri, String selection, String[] selectionArgs) {\n        return 0;\n    }\n\n    @Override\n    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {\n        return 0;\n    }\n\n    @Override\n    public void attachInfo(Context context, ProviderInfo providerInfo) {\n        if (providerInfo == null) {\n            throw new NullPointerException(\"DebugDBInitProvider ProviderInfo cannot be null.\");\n        }\n        // So if the authorities equal the library internal ones, the developer forgot to set his applicationId\n        if (\"com.amitshekhar.debug.DebugDBInitProvider\".equals(providerInfo.authority)) {\n            throw new IllegalStateException(\"Incorrect provider authority in manifest. Most likely due to a \"\n                    + \"missing applicationId variable in application\\'s build.gradle.\");\n        }\n        super.attachInfo(context, providerInfo);\n    }\n\n}\n","sourceCodeStart":58,"sourceCodeEnd":87,"githubUrl":"https://github.com/amitshekhariitbhu/Android-Debug-Database/blob/bf149df61f03e7191f0a0cc71dfb2352f91173b2/debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java#L58-L87","documentation":"DebugDBInitProvider.attachInfo (debug-db module) throws NullPointerException when the Android framework supplies a null ProviderInfo during provider registration. DebugDB needs the resolved ProviderInfo (authority) to finish its initialization hook, so a null value is treated as a broken registration and fails immediately. This mirrors the guard in the encrypt variant of the library.","triggerScenarios":"attachInfo(Context, ProviderInfo) is invoked with providerInfo == null (line 76 check) — e.g., the provider is instantiated manually in a test, or the merged manifest's provider entry for com.amitshekhar.debug.DebugDBInitProvider is missing/corrupted so the framework hands over no valid ProviderInfo.","commonSituations":"Unit tests calling new DebugDBInitProvider().attachInfo(context, null); manifest merger conflicts removing the library provider; app manifest overriding the provider without authorities; build variants excluding the debug-db manifest.","solutions":["Check the merged manifest (app/build/intermediates/merged_manifests) contains com.amitshekhar.debug.DebugDBInitProvider with a valid android:authorities.","Remove tools:node=\"remove\" overrides or manifest filters that strip the library provider.","If instantiating in tests, pass a real ProviderInfo: ProviderInfo info = new ProviderInfo(); info.authority = \"test.authority\"; provider.attachInfo(context, info);","Declare the provider yourself with android:authorities=\"${applicationId}.DebugDBInitProvider\" if you must override it.","Clean and rebuild to eliminate stale manifest merger artifacts."],"exampleFix":"// before (test code)\nDebugDBInitProvider provider = new DebugDBInitProvider();\nprovider.attachInfo(context, null);\n\n// after\nProviderInfo info = new ProviderInfo();\ninfo.authority = \"com.example.myapp.DebugDBInitProvider\";\nDebugDBInitProvider provider = new DebugDBInitProvider();\nprovider.attachInfo(context, info);","handlingStrategy":"validation","validationCode":"// Verify the provider registration before touching DebugDB APIs\nPackageManager pm = context.getPackageManager();\nProviderInfo info = pm.getProviderInfo(new ComponentName(context, \"com.amitshekhar.debug.DebugDBInitProvider\"), 0);\nif (info == null || info.authority == null) {\n    throw new IllegalStateException(\"DebugDBInitProvider is not properly merged into the manifest\");\n}","typeGuard":"boolean hasValidProviderInfo(ProviderInfo info) {\n    return info != null && info.authority != null && !info.authority.isEmpty();\n}","tryCatchPattern":"try {\n    DebugDBInitialize.init(this);\n} catch (NullPointerException | IllegalStateException e) {\n    Log.e(\"DebugDB\", \"Init provider failed: \" + e.getMessage());\n}","preventionTips":["Let the framework instantiate DebugDBInitProvider; never call attachInfo(context, null) in tests.","Keep the library's provider entry intact in the merged manifest (audit tools:node overrides).","Re-check manifest merge report after adding libraries that declare providers.","Run ./gradlew clean before release/debug builds after manifest changes."],"tags":["android","content-provider","manifest","null-argument"],"backgroundTag":"null-argument","analyzedSha":"bf149df61f03e7191f0a0cc71dfb2352f91173b2","analyzedAt":"2026-09-12T15:02:14.977Z","contentChangedAt":"2026-09-12T15:02:14.977Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}