您的位置:首页 > 移动开发 > Unity3D

Unity3D-Android导出APK出现“Unable to convert classes into dex format.”

2017-12-27 14:55 465 查看
今天在更新android版本的时候,导出又出现这个问题了,上次是因为有重复的,但是这次没有重复,看提示是什么东西超过限制

在网上查了一大堆,最后也没解决。

导出时log如下:

CommandInvokationFailure: Unable to convert classes into dex format.

/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/guojicheng/Documents/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar"
-

stderr[

trouble writing output: Too many field references to fit in one dex file: 100424; max is 65536.

You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.

References by package:

     2 android.accounts

    29 android.app

     1 android.content

    43 android.content.pm

    10 android.content.res

     3 android.database

    47 android.graphics

     1 android.hardware
     1 android.location

后面还有很多,一大堆,这也看不出什么问题。

在Unity之前的版本是可以通过在 AndroidManifest 中增加 

android:name="android.support.multidex.MultiDexApplication"

然后在 mainTemplate 文件增加

compile 'com.android.support:multidex:1.0.1'

multiDexEnabled true

但是按照官方文档的改也没有解决,我使用的Unity5.6.4f1,在是在没办法之后,

看到Unity论坛里面有人说了这个事,而且是在14年就有这个问题

那么就像现在这个版本是不是已经默认加了这些参数呢?

然后在Unity的Build Settings里面找到方法了,只需要将 Build System 改为 Gralde 就可以了!



如上图所示,改成改系统之后,可以到处APK了,试了下在真机上跑,也没问题,在此记录下~哈哈
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Unity3d android apk
相关文章推荐