0
\$\begingroup\$

How to replicate this error...

  • Create a new Unity project.

  • Import the facebook sdk unitypackage

  • Set your App Id for facebook via Facebook\Edit Settings

  • Using Assets\External dependency manager\Android, press 'Resolve dependencies', then press 'delete resolved libraries' (otherwise the build will fail at the gradle stage)

  • Build and run.

  • When the app tries to run I immediately get the error message on my phone 'app has stopped working' and see this error in the logs ...

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" on path: DexPathList[[zip file "/data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/base.apk"],nativeLibraryDirectories=[/data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/lib/arm64, /data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
    

Suggested fixes I've tried from here

  1. I've tried different combinations of old or new facebook sdks and old or new versions of Unity.

  2. I've tried building from a few different machines to different Android devices.

  3. I've deleted the external dependency manager included with the facebook sdk and used this one instead. In order to get this one to resolve I had to set a 'Custom Gradle Properties Template'in the player setting under publishing settings.

  4. I've set a Custom Proguard file'in the player setting under publishing settings, and I added the following two lines to the file..

    -keep class com.facebook.internal.* {*;}
    -keep class com.facebook.* {*;}
    

So I've tried all the suggested fixes and various combinations thereof. I dont know what more I can do. Can anyone suggest anything else to try?

\$\endgroup\$
0
\$\begingroup\$

Ok heres one specific method I followed where it worked.

  • Unity version: 2019.3.15f1

  • Facebook SDK version: 7.21.2

  • Using the PlayServicesResolver, Resolve libraries

  • Do not Delete Resolved Libraries

  • Set a Custom Proguard file in the player setting under publishing settings, and add the following two lines to the file..

      -keep public class com.facebook.**{public *; } 
      -keep public class com.facebook.internal.**{ public *; }
    
  • Comment out these lines from mainTemplate.gradle

         com.android.support:appcompat-v7
         com.android.support:support-v4
         com.android.support:customtabs
    

So your mainTemplate.gradle will look something like this...

    `// Android Resolver Repos End
    apply plugin: 'com.android.library'

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0' 
    // Android Resolver Dependencies Start
        //implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
        //implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
        //implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency

        implementation 'com.facebook.android:audience-network-sdk:6.0.0' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8
        implementation 'com.facebook.android:facebook-applinks:[7.1.0, 8)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
        implementation 'com.facebook.android:facebook-share:[7.1.0, 8)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8
        implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
        implementation 'com.facebook.android:facebook-gamingservices:[7.1.0, 8)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:9
        implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4
        implementation 'com.facebook.android:facebook-core:[7.1.0, 8)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5
        implementation 'com.facebook.android:facebook-login:[7.1.0, 8)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7
        implementation 'com.google.android.gms:play-services-ads:19.4.0' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8
        implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17
        implementation 'com.google.android.gms:play-services-basement:17.2.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25
    // Android Resolver Dependencies End
    **DEPS**}`
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.