将Fabric与Multidex一起用于导出的Unity项目 [英] Using Fabric with Multidex with an exported Unity project
问题描述
我已经导出了Unity项目以能够使用multidex.问题是,当我已经为Fabric设置了此"io.fabric.unity.android.FabricApplication"时,我必须将项目的androidmanifest中的android:name设置为"android.support.multidex.MultiDexApplication".
I have exported my Unity project to be able to use multidex. Problem is I have to set the android:name in the project's androidmanifest to "android.support.multidex.MultiDexApplication" when I already have this "io.fabric.unity.android.FabricApplication" set for fabric.
我尝试手动初始化Fabric,但随后出现此错误: AndroidJavaException:io.fabric.unity.android.FabricInitializationException:Fabric找不到有效的应用程序上下文.
I have tried initializing Fabric manually but then I get this error : AndroidJavaException: io.fabric.unity.android.FabricInitializationException: Fabric did not find a valid application context.
我发现有人遇到了类似的问题,但是并没有解决: https://twittercommunity.com/t/unity-android- plugin-conflicts/79947?source_topic_id = 83751
I have found that someone had a similar problem but it didn't got solved: https://twittercommunity.com/t/unity-android-plugin-conflicts/79947?source_topic_id=83751
提前感谢您的帮助!
推荐答案
在您的Application
方法中添加下一行:
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);
}
此外,您可以在此处查看另一个解决方案,我创建了一个小的 GitHub存储库说明如何通过几次单击即可实现.
Also, one more solution you can check here, I created a small GitHub repo with description how to make it in few clicks.
这篇关于将Fabric与Multidex一起用于导出的Unity项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!