Java.lang.RuntimeException: Unable to get provider

My application cannot 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 correct and consistent, so I'm not sure why it cannot find the class.

+4
source share
4 answers

The privilege attribute must match the AUTHORITY constant defined in the DatabaseProvider class, as well as the privileges used with the URI. The name attribute must be the fully qualified class name of the content provider.

+2
source
 // 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" /> 
0
source

Try initializing your database in the ContentProvider onCreate method (if you haven’t already). It can also lead to the error you are getting.

 //something like @Override public boolean onCreate() { myOpenHelper = new MyOpenHelper(getContext()); return true; } 
0
source

I think your manifest does not have a dot (".") In front of the provider name: Android: name = "** ** org.worldsproject.android.barcode.database.DatabaseProvider"

0
source

Source: https://habr.com/ru/post/1496846/


All Articles