What's "com.ansca.corona.storage.FileContentProvider", why is it missing for some Android devices?

Some of my Android users complain that after upgrading to my new version, the app cannot be started. 

I guess the app crashes when it’s launch and there is one Android crash report that might be related to this:

java.lang.RuntimeException: Unable to get provider com.ansca.corona.storage.FileContentProvider: java.lang.ClassNotFoundException: com.ansca.corona.storage.FileContentProvider at android.app.ActivityThread.installProvider(ActivityThread.java:4748) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4500) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4454) at android.app.ActivityThread.access$1300(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:4945) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: com.ansca.corona.storage.FileContentProvider at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.ActivityThread.installProvider(ActivityThread.java:4733) ... 12 more

What’s “com.ansca.corona.storage.FileContentProvider”? Why is it missing for some Android devices? 

Is this a bug or?

I am running into the same issue. Would love to know if you found a solution.

This error should only happen to Corona Enterprise developers when the AndroidManifest.xml file is misconfigured.  Or developers who “hack” the AndroidManifest.xml file and misconfigure it.  This error should never happen to those who build via the Corona Simulator and never hack the built APK afterwards.

What we do is validate the AndroidManifest.xml file on startup to ensure that the FileContentProvider is using your app’s package name.  If not, then we display an alert dialog onscreen informing the developer that it is misconfigured.  That same alert dialog also tells you how to fix the AndroidManifest.xml file issue.  Because if it is not fixed, then your app will crash when the Android OS fails to find the FileContentProvider class within your APK.  The alert message on startup should look something like this…

   “The AndroidManifest.xml provider “FileContentProvider” is misconfigured. Please change its ‘authorities’ attribute value to “<Your-Package-Name>”.”

If you’re running into the above, then you should be able to easily reproduce this issue when you launch the app on your own Android devices.  This is a common mistake that native Android developers make and we find that this validation on startup helps developers resolve this on their own without having to contact tech-support.

http://stackoverflow.com/questions/6303285/classnotfoundexception-for-a-contentprovider

https://code.google.com/p/android/issues/detail?id=23201

There are others who have the same issue and no one has been able to definitively say why it happens.  One guess is that it has to do with upgrades/new installs on certain devices.

I am a Pro subscriber & didnt do  anything about this.

Why is it still happening to my app?

I am a Pro subscriber.

And I don’t hack the AndroidManifest.xml. I don’t think I have “misconfigured” it because I don’t even know what it is.

However, I have received this crash report from my Android users more than once recently.

I have never received this crash report before.

I think there is something wrong at Corona end, not mine.

Corona, could you investigate on this? 

Sorry about not getting back to you.

We’re not able to reproduce this issue.

Are you using any plugins?  If so, then can you please list out all of the ones your are using?

I also need you to post what your “build.settings” file looks like.

And I need to know which Corona “build number” you have built your app with.

One final question.  Are you able to reproduce this issue on your own devices?

Whatever information you can provide will help expedite this matter.  Thanks in advance.

@Joshua

(1) Yes, I am using plugins, here is my build.settings at the end.

(2) The build number should be #2155

(3) I cannot reproduce this issue on my devices. I see the crash reports from Google Play Development Console. The crashes were experienced by the actual users. It does not happen often though. I think there are thousands of app usage per day but this crash only happen twice in 7 days. 

settings = { orientation = { default = "portrait", supported = { "portrait" } }, iphone = { plist = { UIStatusBarHidden = true, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png", }, CFBundleDisplayName = "MyApp", } }, -- Android permissions android = { versionCode = "1611", usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_FINE\_LOCATION", -- Fetches location via GPS. "android.permission.ACCESS\_COARSE\_LOCATION", -- Fetches location via WiFi or cellular service. "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, usesFeatures = { { name = "android.hardware.location", required = false }, { name = "android.hardware.location.gps", required = false }, { name = "android.hardware.location.network", required = false }, }, }, plugins = { ["CoronaProvider.native.popup.social"] = { publisherId = "com.coronalabs", -- supportedPlatforms = { iphone = true }, }, ["CoronaProvider.analytics.flurry"] = { publisherId = "com.coronalabs", }, ["CoronaProvider.ads.iads"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs", -- supportedPlatforms = { android = true }, }, }, }

The social plugin that you are using is the only plugin (that I’m aware of) that uses the FileContentProvider that you are seeing in the log.  Try using the social plugin features on your own Android device to see if you can reproduce it for yourself.  Particularly posting a file/image to the social service, which I suspect might be triggering this.  Just trying to narrow down the issue, because we’re not sure what the cause is yet.

I cannot reproduce this problem. However, I did get one more crash report today with exactly the same call trace.

Please note that this bug does not happen often at all. Probably once every thousands of app sessions.

Therefore, in order to solve this bug, probably you have to look at the call trace report generated when it crashes.

java.lang.RuntimeException: Unable to get provider com.ansca.corona.storage.FileContentProvider: java.lang.ClassNotFoundException: com.ansca.corona.storage.FileContentProvider in loader dalvik.system.PathClassLoader[/mnt/asec/tw.com.appstudio.app.myapp-2/pkg.apk] at android.app.ActivityThread.installProvider(ActivityThread.java:3565) at android.app.ActivityThread.installContentProviders(ActivityThread.java:3317) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3273) at android.app.ActivityThread.access$2200(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3691) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: com.ansca.corona.storage.FileContentProvider in loader dalvik.system.PathClassLoader[/mnt/asec/tw.com.appstudio.app.myapp-2/pkg.apk] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) at java.lang.ClassLoader.loadClass(ClassLoader.java:551) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at android.app.ActivityThread.installProvider(ActivityThread.java:3550) ... 12 more

The thing is, the crash is not happening in our code.  The stack trace you gave me is proof of this.  The Android operating system is failing to find Corona’s “com.ansca.corona.storage.FileContentProvider” class, which definitely exists within the Corona library.

I’m actually wondering if we’re running into a bug with the Android OS that we might have to work-around.  The curious part about the stack trace here is that I see a “tw.com.appstudio.app.myapp-2” for your package name.  I’m guessing your package name does not have a “-2” in it, so it sounds like this is a 2nd copy of your APK on the device.  I think that situation can happen when someone uses Android 4.3’s “restricted profile” feature.  I know that a restricted profile account gets its own application data directory, but the trace suggests that they got their own copy of the APK as well… making me think that its using an older version of your APK that does not contain the Corona class mentioned above.

Does Google Play provide any information about the device model and OS version these crashes happened on?

The device model & OS version:

- HTC Sensation XL / Android 4.0.3~4.0.4

- Galaxy Beam (GT-I8530) / Android 2.3.3-2.3.7

My package name does not contain “-2”. If it’s something that belongs to the users’ fault, I think it’s ok to ignore this issue. For one more information, a user left a crash report message “cannot start the app”. I guess the crash happens when the app launches.

Hmm… I’m not sure what could possible be wrong.  It sounds like a bug in the Android OS (or a forked version of the OS) because other native Android developers have raised this same issue up here…

   https://code.google.com/p/android/issues/detail?id=23201

Based on what I’ve read, some native Android developers believe that this issue happen when the install application becomes corrupted.  In which case, the solution is to re-install the app.  So, that’s what I’d recommend that you tell your customers to do.  Not sure what else to advise.

I think you are right. It’s probably Android OS bug.

If there is some unusual development for this issue, I will update this post.

Thanks for the help.

I am running into the same issue. Would love to know if you found a solution.

This error should only happen to Corona Enterprise developers when the AndroidManifest.xml file is misconfigured.  Or developers who “hack” the AndroidManifest.xml file and misconfigure it.  This error should never happen to those who build via the Corona Simulator and never hack the built APK afterwards.

What we do is validate the AndroidManifest.xml file on startup to ensure that the FileContentProvider is using your app’s package name.  If not, then we display an alert dialog onscreen informing the developer that it is misconfigured.  That same alert dialog also tells you how to fix the AndroidManifest.xml file issue.  Because if it is not fixed, then your app will crash when the Android OS fails to find the FileContentProvider class within your APK.  The alert message on startup should look something like this…

   “The AndroidManifest.xml provider “FileContentProvider” is misconfigured. Please change its ‘authorities’ attribute value to “<Your-Package-Name>”.”

If you’re running into the above, then you should be able to easily reproduce this issue when you launch the app on your own Android devices.  This is a common mistake that native Android developers make and we find that this validation on startup helps developers resolve this on their own without having to contact tech-support.

http://stackoverflow.com/questions/6303285/classnotfoundexception-for-a-contentprovider

https://code.google.com/p/android/issues/detail?id=23201

There are others who have the same issue and no one has been able to definitively say why it happens.  One guess is that it has to do with upgrades/new installs on certain devices.

I am a Pro subscriber & didnt do  anything about this.

Why is it still happening to my app?

I am a Pro subscriber.

And I don’t hack the AndroidManifest.xml. I don’t think I have “misconfigured” it because I don’t even know what it is.

However, I have received this crash report from my Android users more than once recently.

I have never received this crash report before.

I think there is something wrong at Corona end, not mine.

Corona, could you investigate on this? 

Sorry about not getting back to you.

We’re not able to reproduce this issue.

Are you using any plugins?  If so, then can you please list out all of the ones your are using?

I also need you to post what your “build.settings” file looks like.

And I need to know which Corona “build number” you have built your app with.

One final question.  Are you able to reproduce this issue on your own devices?

Whatever information you can provide will help expedite this matter.  Thanks in advance.