Error while using Facebook sdk and google Admob ad plugin

Hello everyone.

I am facing really big problem as i have tried to solve since one week.

I have installed facebook SDK plugin first. Which i was able to run on device. I was able to build apk file easily and Facebook login worked as expected.

Then i added Google admob SDK. Then i set up admob App ID and tried to build apk and i got build error.

gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease" 
stderr[ Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 D8: Cannot fit requested classes in a single dex file (# methods: 74418 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K.

Then i resolved above error by :

Assets > External Dependancy Manager > Android Resolver > Delete Resolved Libraries.

Then i was able to build apk.

But unfortunately i got runtime error for Facebook sdk :

 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.DefaultCompany.CookingMaster-1/base.apk"],nativeLibraryDirectories=[/data/app/com.DefaultCompany.CookingMaster-1/lib/arm, /data/app/com.DefaultCompany.CookingMaster-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
        at android.app.ActivityThread.installProvider(ActivityThread.java:6877)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6469)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6409)
        at android.app.ActivityThread.access$1800(ActivityThread.java:229)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)

So please help me to solve this.

I am using Facebook SDk version 11.0.0 and GoogleAdmob version is 6.1.2.

Unity version is 2020.3.21f1.

I am not using any other plugin. i have taken fresh project which only includes Facebook sdk and google admob plugin.

I had this error before too. This is so annoying. There is few solution but these are not quarantee.

1 - Change Minimum API level to Android 5.0 Lollilop.

2 - “Assets/External Dependency Manager/Android Resolver/Force Resolver” try this.

3 - You can try this: Unity Android 빌드시 Error:) The Option 'Android.Enabler8' Is Deprecated blah blah~.

4 - Close the Unity Editor, delete Libray and reopen project.

5 - Open Custom Main Gradle Template and Custom Launcher Gradle Template.

I hope these help you.