本文介绍了太多的字段参考:70613;最大值是65536的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用以下插件:

My project uses these plugins:

  • OneSignal
  • GooglePlayServices
  • 调整
  • Google Analytics(分析)
  • 统一IAP
  • Facebook SDK

这些插件几乎用在每个项目中.

Those plugins are used in almost every project.

但是我超出了字段引用计数

But I am over field references count

这是我的.aar文件列表

This is my .aar file list

我该怎么做以减少引用计数?

What should I do to decrease reference count?

推荐答案

您有许多具有许多功能/字段的插件.从Unity的编辑器进行构建时有一个限制,而您已经达到该限制.

You have so many plugins with many functions/fields. There is a limit when building this from Unity's Editor and you have reached that limit.

要减少参考数量,您必须删除其中一些插件,但是我确定您需要它们,在这种情况下,删除可能不是合适的解决方案.

To decrease reference count, you have to delete some these plugins but I am sure that you need them and deletion may not be the appropriate solution in this case.

目前解决此问题并为Android构建的 only 方法是 将项目导出为Android项目,然后使用Android Studio进行构建.这消除了Unity编辑器施加的参考限制.

The only way to actually get around this and build for Android at this moment is to export the Project as Android Project then build it with Android Studio. This removes the reference limit imposed by Unity's Editor.

编辑

我忘了提到您要在导出多义词后启用它.由于很多人每天都会遇到此问题,因此我决定添加完整的说明,说明如何通过导出来解决此问题以及不导出来解决此问题.

I forgot to mention that you have to enable multidex after exporting it out. Since many people go through this problem daily, I decided to add a thorough instruction on how to fix this problem by exporting it out and also how to fix it without exporting it.

1A .将Unity项目导出为Android项目.

1A.Export the Unity Project as Android Project.

1B .导入Android Studio:

1B.Import into Android Studio:

如果您在导入Android Studio时遇到等级错误,如下所示:

If you get grade error when importing into Android Studio like the one below:

build.gradle 文件的"buildscript"块中的"dependencies"块中,更改:

In the "dependencies" block which is in the "buildscript" block in the build.gradle file, change:

classpath 'com.android.tools.build.gradle.2.1.0'

classpath 'com.android.tools.build:gradle:2.2.3'

如果导出项目后仍然出现相同的错误,则需要手动启用multidex.以下是Google的 doc 的简化步骤,该文档将在错误:

If you export the Project and still get the-same error, you need to manually enable multidex. Below is a simplified step to follow from Google's doc that will be shown to you in the error:

2 .将android:name="android.support.multidex.MultiDexApplication" >添加到 AndroidManifest.xml 文件中的 application 标签.

2.Add android:name="android.support.multidex.MultiDexApplication" > to theapplication tag in the AndroidManifest.xml file.

3 .将compile 'com.android.support:multidex:1.0.1'添加到 build.gradle 文件中的依赖项" 块中.

3.Add compile 'com.android.support:multidex:1.0.1' to the "dependencies" block in the build.gradle file.

4 .将multiDexEnabled true添加到 build.gradle 文件中"android"块中的"defaultConfig" 块中

4.Add multiDexEnabled true to the "defaultConfig" block which is in the "android" block in the build.gradle file.

构建APK并查看其是否有效.如果参考计数错误消失,请在此处停止.

Build APK and see if it works. If the reference count error is gone, stop here.

5 .是否遇到类似下面的GC开销异常?

5.Getting a GC overhead exception like the one below?

增加执行dex操作时将使用的堆大小.在此解决方案中,将以下内容添加到"android " build.gradle 文件中的块:

Increase the heap size that will be used when performing dex operation. From this solution, add the following to the "android" block in the build.gradle file:

dexOptions {
    javaMaxHeapSize "4g"
}

必须具有Unity 5.5及更高版本才能执行此操作:

Must have Unity 5.5 and above to do this:

1 .转到<UnityInstallationDirecory>\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates,将mainTemplate.gradle文件复制到您的<ProjectName>Assets\Plugins\Android文件夹中.

1.Go to <UnityInstallationDirecory>\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates, Copy the mainTemplate.gradle file to your <ProjectName>Assets\Plugins\Android folder.

2 .转到<UnityInstallationDirecory>\Editor\Data\PlaybackEngines\AndroidPlayer\Apk,将AndroidManifest.xml文件复制到您的<ProjectName>Assets\Plugins\Android

2.Go to <UnityInstallationDirecory>\Editor\Data\PlaybackEngines\AndroidPlayer\Apk, Copy the AndroidManifest.xml file to your <ProjectName>Assets\Plugins\Android

3 .打开您刚才用Visual Studio复制的mainTemplate.gradleAndroidManifest.xml文件,然后根据上面的 FIX by EXPORTING PROJECT 指令进行修改.跳过/忽略步骤#1A #1B .只需执行从#2 #5 的步骤.而已.

3.Open both the mainTemplate.gradle and AndroidManifest.xml file you just copied with Visual Studio then do the modification from the FIX BY EXPORTING THE PROJECT instruction above. Skip/Ignore step #1A and #1B. Just do steps from #2 to #5. That's it.

是最终的 mainTemplate.gradle 应该看起来像,就是最终的 AndroidManifest.xml 应该看起来像.这仅供参考.我建议您不要使用我的,而是按照上面的复制步骤来创建您的副本,因为将来的Unity版本可能附带不同的文件.您要确保使用最新的版本,否则在构建它时可能会遇到问题.

This is what the final mainTemplate.gradle should look like and this is what the final AndroidManifest.xml should look like. This is only for reference purposes. I suggest you don't use mine but instead follow the copy steps above to create yours because future Unity versions can come with different files. You want to make sure you use the latest one or you may have problems building it.

4 .构建APK并查看其是否有效:

4.Build APK and see if it works:

-

如果引用计数错误消失,请在此处停止:

If the reference count error is gone, stop here:

5 .遇到类似以下错误吗?

5.Getting an error like the one below?

只需签名 发布设置中的构建设置.您可以创建新的密钥库,也可以使用现有的密钥库.

Just sign the apk from the Publishing Settings in the Build Settings. You can create new keystore or use an existing one.

6 .还有另一个错误,如下所示?

6.Another error like below?

AndroidManifest.xml文件中删除android:debuggable="true">.

如果此非导出解决方案对您不起作用,那么您必须使用导出解决方案.

If this non exporting solution did not work for you then you have touse the exporting solution.

这篇关于太多的字段参考:70613;最大值是65536的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:47
查看更多