Skip to content Skip to sidebar Skip to footer

Classnotfoundexception For A Contentprovider

I have a ContentProvider class and is declared in AndroidMenifest.xml like this:

I have the same crash reported in the market for my app. The stack traces look identical, and the error is occurring at installProvider. I have about 15 test phones in my office and none of them can reproduce this problem. Any other ideas would be appreciated.

Fully qualified names in the manifest are only necessary if your java package names are not the same as your android package name. If a fully qualified name is not specified, the OS will automatically prepend the android package name to the class name specified in the manifest.

Solution 2:

Ensure twice that you have correct qualified class name specified in AndroidManifest.xml, it must read something like this:

<providerandroid:authorities="org.iii.romulus.meridian.mediasearch"android:name="org.iii.romulus.meridian.MediaSearchProvider"></provider>

Notice that @name is fully qualified.

Solution 3:

This sounds similar to an issue I had that was caused by an issue with the ClassLoader, see here: Bizarre behaviour when using Apache Commons lib in Android

This bug discusses an error relating to the class loader failing sometimes. The fix for me was to add this line:

Thread.currentThread().setContextClassLoader(this.getClassLoader());

in the constructor of the class that was calling the code that was failing.

Solution 4:

Proguard excludes all inherited content providers by default with this line (make sure it's in your cfg):

-keep publicclass * extendsandroid.content.ContentProvider

If you have any additional inheritance you should exclude it as well or exclude your specific Content Provider class, for example:

-keep publicclassorg.iii.romulus.meridian.MediaSearchProvider

Solution 5:

This is an old thread, and the OP didn't have the same ContentProvider declaration as me, but I had the same exact error, so I want to share my findings, in case it helps anyone.

For me, what caused the problem was that the ContentProvider declaration in the AndroidManifest.xml had an exported attribute set to true:

android:exported="true"

Removing it fixed the problem for me. (I didn't really need it)

Post a Comment for "Classnotfoundexception For A Contentprovider"