0

This whole thing should be easy but I still cannot get it right

I added the Facebook login implementation to my app build.gradle:

implementation 'com.facebook.android:facebook-login:[5,6)'

I made sure that the following is implemented in my project build.gradle:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

When I synch and run I receive the following error:

Cannot fit requested classes in a single dex file (# methods: 71724 > 65536)

There is an explanation how to solve it here by installing MultiDex: MultiDexApplication not recognized

Since I'm using AndroidX, I added in my app build.gradle:

implementation 'androidx.multidex:multidex:2.0.0'

In my manifest file:

<application
    android:name="androidx.multidex.MultiDexApplication"
...

And of course added:

defaultConfig {
        multiDexEnabled true

Now when I run the app, it crashes immediately without giving any error message. When I remove the facebook login implementation, it works fine, so I assume that MultiDex is working properly? What can I do to figure out why my app crashes with facebook login?

I also enabled those in my gradle.properties:

android.useAndroidX=true
android.enableJetifier=true
sir-haver
  • 3,096
  • 7
  • 41
  • 85

3 Answers3

0
create your custom myApplication class that extends MultiDexApplication. and add this class in Android Manifest.xml file

 *Android Manifest.xml

<application
        android:name=".myApplication"

 add after that update your myApplication.java class.
          public class myApplication extends MultiDexApplication {



    @Override
    public void onCreate() {
        super.onCreate();

    }
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }



}
Mayur Rajvir
  • 140
  • 5
0

you should use custom Application, like:

  • App
public class App extends Application {
    @Override
    public void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
  • AndroidManifest.xml
<application
        android:name=".application.App"
Leo Mrko
  • 61
  • 3
0

It seems that the whole problem was caused by Facebook login wasn't the latest version, although the version I used was copied straight from their official docs.

Version I'm using that solved the problem:

implementation 'com.facebook.android:facebook-login:5.13.0'
sir-haver
  • 3,096
  • 7
  • 41
  • 85