vargonian
vargonian

Reputation: 3234

Enabling Multidex in a Unity Android project with Crashlytics

I have a very similar issue as discussed here: Using Fabric with Multidex with an exported Unity project

Both Fabric and Multidex (for older Android versions) require adding an Application subclass to the AndroidManifest.xml file's application tag. But I can't include both without error, and I don't have access to either of these classes in order to modify them and alter the inheritance hierarchy.

(I need both of these together.)
<application ... android:name="android.support.multidex.MultiDexApplication">
<application ... android:name="io.fabric.unity.android.FabricApplication">

Our build uses Gradle (fairly newly supported in Unity) if that opens any avenues.

How can I get around this issue? I'm open to decompiling and rebuilding jars but so far all my efforts to decompile the fabric-init.jar (which contains the Application subclass) have failed.

Upvotes: 2

Views: 1468

Answers (1)

Orest Savchak
Orest Savchak

Reputation: 4569

You can use the custom Application class with next content:

protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    // this one is needed to enable multidex in your application
    MultiDex.install(this);
}

public void onCreate() {
    super.onCreate();
    // this one is needed to init the Fabric SDK
    FabricInitializer.initializeFabric(this, FabricInitializer.Caller.Unity);
}

Also, one more solution you can check here, I created a small GitHub repo with description how to make it in few clicks.

Upvotes: 1

Related Questions