Goodwy / Dialer

GNU General Public License v3.0
64 stars 15 forks source link

Assistance Needed: Error - "Failed to find provider info for com.goodwy.commons.contactsprovider" #58

Closed biencuong closed 6 days ago

biencuong commented 3 weeks ago

I am encountering an issue in my application and need your assistance. The error message I am seeing is: Failed to find provider info for com.goodwy.commons.contactsprovider I have ensured that I’ve correctly declared the ContentProvider in my AndroidManifest.xml file with the following configuration: <provider android:name="com.goodwy.commons.ContactsProvider" android:authorities="com.goodwy.commons.contactsprovider" android:exported="true" /> Despite this, the application is unable to find the provider. Could you please help me resolve this issue? I would appreciate any guidance on ensuring that the provider is correctly set up and accessible.

Thank you for your support.

Best regards,

biencuong commented 3 weeks ago

Here's the guide in English to set up the ContactsProvider class and ensure it works correctly:

Here's the guide in English to set up the ContactsProvider class and ensure it works correctly:

  1. Create the Folder Structure Navigate to the root folder of your project, typically app/. Create directories to follow this structure: src/main/kotlin/com/goodwy/commons/. In Android Studio, you can right-click the src/main/kotlin folder, select "New > Directory," and sequentially create the folders com, then goodwy, and finally commons.
  2. Create the ContactsProvider Class Once the commons folder is ready, create a new file named ContactsProvider.kt inside it. Add the following code to ContactsProvider.kt:

package com.goodwy.commons import android.content.ContentProvider import android.content.ContentValues import android.database.Cursor import android.net.Uri class ContactsProvider : ContentProvider() { override fun onCreate(): Boolean { return true } override fun query( uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String? ): Cursor? { return null } override fun insert(uri: Uri, values: ContentValues?): Uri? { return null } override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int { return 0 } override fun update( uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array? ): Int { return 0 } override fun getType(uri: Uri): String? { return null } }

  1. Declare ContactsProvider in AndroidManifest.xml After creating the ContactsProvider class, update your AndroidManifest.xml with the following entry inside the tag: <provider android:name="com.goodwy.commons.ContactsProvider" android:authorities="com.goodwy.commons.contactsprovider" android:exported="false" />

After completing these steps, try rebuilding and running the project. This should resolve issues with the ContactsProvider class, and the setup should now work correctly.

Goodwy commented 3 weeks ago

What version of the app do you have installed and what operating system is on your device? At what point do you receive an error message? Have you had this error before or is it caused by some action?