amitshekhariitbhu/Android-Debug-Database · error · NullPointerException
DebugDBEncryptInitProvider ProviderInfo cannot be null.
Error message
DebugDBEncryptInitProvider ProviderInfo cannot be null.
What it means
DebugDBEncryptInitProvider.attachInfo throws this NullPointerException when the Android framework passes a null ProviderInfo into attachInfo during content-provider registration. The library requires valid provider metadata (authority string) to initialize the encrypted debug database, so it fails fast rather than continuing with a broken registration. This almost always indicates the provider was not properly declared/merged in the merged AndroidManifest.
Solutions
- Verify the library's provider is present in the merged manifest: check app/build/intermediates/merged_manifests for com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider.
- Remove any tools:node="remove" override or manifest exclusion that strips the provider declaration.
- If overriding the provider yourself, declare it with a valid android:authorities attribute using ${applicationId}.provider.
- Do not instantiate DebugDBEncryptInitProvider manually; let the Android framework create it so attachInfo receives a valid ProviderInfo.
- Clean and rebuild (./gradlew clean :app:assembleDebug) to rule out stale manifest merger output.
Example fix
// before (AndroidManifest.xml) - provider removed
<provider android:name="com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider" tools:node="remove" />
// after - provider declared with applicationId-based authority
<provider
android:name="com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider"
android:authorities="${applicationId}.DebugDBEncryptInitProvider"
android:exported="false" /> Defensive patterns
Strategy: validation
Validate before calling
// At startup, verify the provider is registered with a valid authority in the merged manifest
PackageManager pm = context.getPackageManager();
ComponentName cn = new ComponentName(context, "com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider");
ProviderInfo info = pm.getProviderInfo(cn, 0);
if (info.authority == null || info.authority.equals("com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider")) {
throw new IllegalStateException("DebugDBEncryptInitProvider authority not substituted - check applicationId in build.gradle");
} Type guard
boolean isValidProviderInfo(ProviderInfo info) {
return info != null && info.authority != null && !info.authority.isEmpty();
} Try / catch
try {
DebugDBEncryptInitialize.init(this);
} catch (NullPointerException | IllegalStateException e) {
Log.e("DebugDB", "Provider init failed: " + e.getMessage());
} Prevention
- Never remove or override the library's provider declaration in your manifest without re-declaring it with ${applicationId}.
- Keep applicationId set in defaultConfig and review it in code review for new modules/flavors.
- Inspect the merged manifest when adding new libraries with content providers.
- Do not instantiate ContentProviders manually outside the Android framework.
When it happens
Trigger: Android framework instantiates DebugDBEncryptInitProvider and calls attachInfo(Context, ProviderInfo) with providerInfo == null (line 53 check). This happens when the provider declaration is malformed or stripped from the merged manifest, or when the provider is instantiated outside normal framework registration (e.g., manually in tests) without supplying ProviderInfo.
Common situations: Manifest merger removing or corrupting the library's provider entry; overriding the provider in the app manifest with tools:node="remove" then still triggering init; unit/instrumentation tests constructing the provider manually; build variants where the debug-db-encrypt manifest is excluded.
Related errors
- DebugDBInitProvider ProviderInfo cannot be null.
- Incorrect provider authority in manifest. Most likely due…
- Incorrect provider authority in manifest. Most likely due…
AI-assisted analysis of amitshekhariitbhu/Android-Debug-Database@bf149df61f (2026-09-12).
Data as JSON: /api/errors/3d21a39513541dc0.
Report an issue: GitHub.
Appendix: source
Thrown at debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/DebugDBEncryptInitProvider.java:53
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
@Override
public void attachInfo(Context context, ProviderInfo providerInfo) {
if (providerInfo == null) {
throw new NullPointerException("DebugDBEncryptInitProvider ProviderInfo cannot be null.");
}
// So if the authorities equal the library internal ones, the developer forgot to set his applicationId
if ("com.amitshekhar.debug.encrypt.DebugDBEncryptInitProvider".equals(providerInfo.authority)) {
throw new IllegalStateException("Incorrect provider authority in manifest. Most likely due to a "
+ "missing applicationId variable in application\'s build.gradle.");
}
super.attachInfo(context, providerInfo);
}
}
View on GitHub (pinned to bf149df61f)