java.lang.RuntimeException: Unable to get provider
Asked Answered
J

4

6

My app is unable to start due to this RuntimeException:

java.lang.RuntimeException: Unable to get provider org.worldsproject.android.barcode.database.DatabaseProvider: java.lang.ClassNotFoundException: org.worldsproject.android.barcode.database.DatabaseProvider

My manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.worldsproject.android.barcode"
android:versionCode="4"
android:versionName="1.0.3" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock" >
    <activity
        android:name="BarcodeSaleTracker"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <provider android:name="org.worldsproject.android.barcode.database.DatabaseProvider"
        android:multiprocess="true"
        android:exported="false"
        android:authorities="org.worldsproject.android.barcode.database.DatabaseProvider" />
</application>

My DatabaseProvider:

package org.worldsproject.android.barcode.database;

public class DatabaseProvider extends ContentProvider{

private static final String TAG = "DatabaseProvider";

private static final String DATABASE_NAME = "sales.db";

private static final int DATABASE_VERSION = 1;

public static final String AUTHORITY = "org.worldsproject.android.barcode.database.DatabaseProvider";

The authority and name attributes are all correct and match, so I'm not sure why it cannot find the class.

Jersey answered 13/8, 2013 at 16:15 Comment(2)
have look here #6303785Elmer
have you made a Project->clean ?Enucleate
A
2

The authorities attribute should match the AUTHORITY constant defined in the DatabaseProvider class as that’s the authority used with the URIs. The name attribute must be the fully qualified class name of the content provider

Atrip answered 13/8, 2013 at 16:27 Comment(1)
They do match, and it is the fully qualified name.Jersey
I
0
// try this
public static final String AUTHORITY = "org.worldsproject.android.barcode.database";

<provider android:name=".database.DatabaseProvider"
                  android:multiprocess="true"
                  android:exported="false"
                  android:authorities=".barcode.database" />
Incommensurate answered 30/9, 2013 at 11:6 Comment(1)
Why android:multiprocess="true"??Legislation
A
0

Try initializing your database in the ContentProvider's onCreate method ( if you are not already doing this). This can also cause that error you are getting.

//something like
@Override
public boolean onCreate() {
    myOpenHelper = new MyOpenHelper(getContext());
    return true;
}
Assemblyman answered 22/6, 2014 at 23:27 Comment(0)
S
0

I think there's a dot (".") missing before the provider's name in your Manifest: android:name="**.**org.worldsproject.android.barcode.database.DatabaseProvider"

Scholiast answered 28/2, 2017 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.