- Home /
Unity Facebook plugin FacebookContentProvider not found runtime exception.
I add facebook plugin to my project, follow all the steps.It is working fine in unity editor. when i tried exporting a build and tested on android device it is not working. The app crash on the initial launch itself.It closes immediately.
I tried connecting the app to the adb logcat and found some errors on the log, which is follows.
java.lang.RuntimeException: Unable to get provider com.facebook.FacebookContentProvider: java.lang.ClassNotFoundException: Didn’t find class “com.facebook.FacebookContentProvider” on path: DexPathList[[zip file “/data/app/com.studio.halfo-1/base.apk”],nativeLibraryDirectories=[/data/app/com.studio.halfo-1/lib/arm, /data/app/com.studio.halfo-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5175)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4767)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.facebook.FacebookContentProvider” on path: DexPathList[[zip file “/data/app/com.studio.halfo-1/base.apk”],nativeLibraryDirectories=[/data/app/com.studio.halfo-1/lib/arm, /data/app/com.studio.halfo-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:5160)
… 10 more
Suppressed: java.lang.ClassNotFoundException: com.facebook.FacebookContentProvider
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
If i tried commenting the FacebookContentProvider in the AndroidManifest.xml file then the app fails on the facebook initialisation. It throws Facebook is not initialised error.
Anyone Please let me know what i am missing on this. My Unity Version is 2018.4.3f1.
,I add facebook plugin to my project, follow all the steps.It is working fine in unity editor. when i tried exporting a build and tested on android device it is not working. The app crash on the initial launch itself.It closes immediately.
I tried connecting the app to the adb logcat and found some errors on the log, which is follows.
java.lang.RuntimeException: Unable to get provider com.facebook.FacebookContentProvider: java.lang.ClassNotFoundException: Didn’t find class “com.facebook.FacebookContentProvider” on path: DexPathList[[zip file “/data/app/com.studio.halfo-1/base.apk”],nativeLibraryDirectories=[/data/app/com.studio.halfo-1/lib/arm, /data/app/com.studio.halfo-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5175)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4767)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.facebook.FacebookContentProvider” on path: DexPathList[[zip file “/data/app/com.studio.halfo-1/base.apk”],nativeLibraryDirectories=[/data/app/com.studio.halfo-1/lib/arm, /data/app/com.studio.halfo-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:5160)
… 10 more
Suppressed: java.lang.ClassNotFoundException: com.facebook.FacebookContentProvider
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
If i tried commenting the FacebookContentProvider in the AndroidManifest.xml file then the app fails on the facebook initialisation. It throws Facebook is not initialised error.
Anyone Please let me know what i am missing on this. My Unity Version is 2018.4.3f1.
Hello guys
I am also facing the same issue I'm using Unity version 2017.4.27f1.
hoping to get some answers to the same.
Try this solution: https://github.com/facebook/facebook-sdk-for-unity/issues/294
I'm facing the same issue on Unity 2019.3.0f6 with Facebook SDK 7.18.1. Hope to find out solution
Try to follow this closed thread
OR the new one here.
Answer by shaldar · Nov 23, 2019 at 03:13 AM
I struggled with the same thing. Crashing on android at the very startup with the provider class not found" error. I was just trying to FB login from the Unity app and get profile picture and name.
I used the latest available FB for Unity SDK (v7.18.0 ). Banged my head around quite a bit - changing AndroidManifest, changing the gradle, messing around with proguard file etc. Nothing worked.
Finally I solved it by using a previous version of Facebook SDK (v7.15. Ithink). This version has a bigger footprint and more libraries. I didn't face the FacebookContentProvider not found problem any more and after a bit of struggle ( duplicate classes and linking issues), I got the build to work on android...
IMHO, the current Facebook SDK version for Unity looks stunted and incomplete. I raised a bug report with no response to date.
Hello
I was able to solve this issue by searching for the FBSD$$anonymous$$ files in the Xcode project then deselect any checkmarks on all the 3 files.
NOTE : Remember to open the "Unity-iPhone.xcworkspace" And not the "Unity-iPhone.xcodeproj".
Hope this helps.
Answer by Kornikolia · Feb 11, 2020 at 02:13 PM
@GunLengend , try to make "clear" resolve of packages:
"/Assets/Play Service Resolver/Android Resolver/Delete Resolved Libraries"
"/Assets/Play Service Resolver/Android Resolver/Resolve"
Should work now (at least works for me FB 7.18.1 & Unity 2019.2.17f1)
This worked for me. On PC the play services resolver didn’t automatically run. Had to do it manually
Answer by Valhalaru · 6 days ago
Facebook Unity SDK Proper Setup and Fixing Didn't find class com.facebook.FacebookContentProvider
Overview
The step by step process of getting the Unity side of FB setup and running by importing the right packages. Also fixes the error –
Error AndroidRuntime java.lang.RuntimeException: Unable to get provider com.facebook.FacebookContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider…”
Steps
Delete any previous Unity Facebook SDKs and re-import the latest. Follow the steps here: https://stackoverflow.com/questions/48275051/unity-cant-build-android-with-facebook-sdk • Delete Facebook SDK folder.
• Delete `PlayServicesResolver folder.
• Delete Plugins Folder.
• Now comment the code using Facebook API and namespaces.
• Now import latest FacebookSDK and configure it with project details in Edit-setting option. In Assets->ImportPackage->CustomPackage->latestFBUnityPackage In my case it was “facebook-unity-sdk-11.0.0”
• Now regenerate Android Manifest file and uncomment the code.
Delete the Assets\PlayServicesResolver Folder again
Download the ExternalDependencyManager and unzip, from here: https://github.com/googlesamples/unity-jar-resolver
In Unity import the “external-dependency-manager-latest” unity package
If the Unity Menu “Assets->ExternalDependencyManager” does not showup goto Assets\ExternalDependencyManager\Editor\1.2.171\, select all the DLLs (in my case there were four). Then In the Unity Inspector for the four DLLs select INCLUDE PLATFORMS->EDITOR. Then hit the “Apply” button
In Unity Assets\FacebookSDK\Plugins\Editor\Dependencies – change the 12 to 11.3.
androidPackage spec="com.facebook.android:facebook-core:[11.0, 11.3)" /> androidPackage spec="com.facebook.android:facebook-applinks:[11.0, 11.3)" /> androidPackage spec="com.facebook.android:facebook-login:[11.0, 11.3)" /> androidPackage spec="com.facebook.android:facebook-share:[11.0, 11.3)" /> androidPackage spec="com.facebook.android:facebook-gamingservices:[11.0, 11.3)" />
In Unity->Player Settings->Android->Publishing – Build – Check the boxes to generate the following: Custom Main Manifest; Custom Main Gradle Template; Custom Gradle Properties Template; Custom Proguard File
In Assets\Plugins\Android – proguard-user.txt – add the following two lines:
-keep class com.facebook.internal.** {public *;} -keep class com.facebook.** {public *; }
In the Unity dropdown menu, select the following option to Resolve the Android dependencies: Assets->ExternalDependencyManager->Android->Resolve Step 9: Solution From - https://github.com/facebook/facebook-sdk-for-unity/issues/509
The error should be resolved and you should be able to run your app with the Facebook SDK. If it doesn’t work, keep working at it, you will get it!
Your answer
Follow this Question
Related Questions
Invite facebook friends? 1 Answer
Facebook sdk for ios 9 is not opening the app when logging in, Why? 1 Answer
Do our company need a Facebook business account for integrating our unity game? 1 Answer
Facebook SDK Login Loads for a long time 0 Answers
Assets/scripts/fbLogin.cs(60,52): error CS1501: No overload for method `API' takes `3' arguments 1 Answer