Using Fabric with Multidex with an exported Unity project

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 05:02:03

Add next lines to your Application method:

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.

Was having the same problem.

Ended up creating a new android studio project. Imported Fabric-(some version).jar and Fabric-init.jar which I got from the android plugins folder inside the Unity project.

Decompiled the Fabric-init.jar and modified the FabricApplication.java class in order to extend from MultiDexApplication instead of Application.

Built the project and extracted the new FabricApplication.class from the build folder in the Android Studio project/app.

Replaced the FabricApplication.class inside the Fabric-init.jar of the Unity project with the new one.

Left "io.fabric.unity.android.FabricApplication" as the application name in the manifest.

Tested in android 4.4 and it worked. Not ideal though because I'll have to do it with every plugin update, but considering I'm a noob with this gradle thing (and Android projects in general), I'm beyond happy that at least it worked.

If anyone comes up with a better approach, please let us know!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!