android - 使用 Crashlytics 在 Unity Android 项目中启用 Multidex

标签 android unity-game-engine android-multidex google-fabric

我有一个与此处讨论的问题非常相似的问题:Using Fabric with Multidex with an exported Unity project

Fabric 和 Multidex(适用于较旧的 Android 版本)都需要将 Application 子类添加到 AndroidManifest.xml 文件的应用程序标记中。但是我不能在没有错误的情况下同时包含这两个类,而且我无权访问这些类中的任何一个来修改它们和改变继承层次结构。

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

我们的构建使用 Gradle(在 Unity 中是新近支持的),如果有的话。

我该如何解决这个问题?我愿意反编译和重建 jar,但到目前为止,我反编译 fabric-init.jar(包含 Application 子类)的所有努力都失败了。

最佳答案

您可以将自定义 Application 类用于下一个内容:

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 repo 并说明如何单击几下即可完成。

关于android - 使用 Crashlytics 在 Unity Android 项目中启用 Multidex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45848610/

相关文章:

c# - 通过Unity引用python脚本

Android Studio 任务compilefreeDebugKotlin 执行失败

3d - Unity3D 是创建交互式人体头像的好选择吗?

android - 将 AndroidX 库包含到 Unity 项目中

c# - Unity - 添加对 GameObject OnMouseDown 事件的回调

android - com.android.build.api.transform.TransformException : java. util.zip.ZipException : duplicate entry: android/support/multidex/MultiDex$V14. 类

android - 无法更改构建工具版本来编译 Android 应用程序

android - 过多的字段引用:70613;最大值是65536

java - 如何在 Android 中获取 Jenkins 内部版本号?

android - Android 模拟器中的外部 SDCard