android - Too many field references: 70613; max is 65536 -
my project uses these plugins:
- onesignal
- googleplayservices
- adjust
- google analytics
- unity iap
- facebook sdk
those plugins used in every project.
but on field references count
what should decrease reference count?
so should decrease reference count ?
you have many plugins many functions/fields. there limit when building unity's editor , have reached limit.
to decrease reference count, have delete these plugins sure need them , deletion may not appropriate solution in case.
the only way around , build android @ moment export project android project build android studio. removes reference limit imposed unity's editor.
edit
i forgot mention have enable multidex after exporting out. since many people go through problem daily, decided add thorough instruction on how fix problem exporting out , how fix without exporting it.
fix exporting project
1a.export unity project android project.
1b.import android studio:
if grade error when importing android studio 1 below:
error:org.gradle.api.internal.tasks.defaulttaskinputs$taskinputunionfilecollection cannot cast org.gradle.api.internal.file.collections.defaultconfigurablefilecollection
in "dependencies" block in "buildscript" block in build.gradle file, change:
classpath 'com.android.tools.build.gradle.2.1.0'
to
classpath 'com.android.tools.build:gradle:2.2.3'
if export project , still the-same error, need manually enable multidex. below simplified step follow google's doc shown in error:
2.add android:name="android.support.multidex.multidexapplication" >
application tag in androidmanifest.xml file.
3.add compile 'com.android.support:multidex:1.0.1'
"dependencies" block in build.gradle file.
4.add multidexenabled true
"defaultconfig" block in "android" block in build.gradle file.
build apk , see if works. if reference count error gone, stop here.
5.getting gc overhead exception 1 below?
java.lang.outofmemoryerror: gc overhead limit exceeded
increase heap size used when performing dex operation. solution, add following "android" block in build.gradle file:
dexoptions { javamaxheapsize "4g" }
fix without exporting project
must have unity 5.5 , above this:
1.go <unityinstallationdirecory>\editor\data\playbackengines\androidplayer\tools\gradletemplates
, copy maintemplate.gradle
file <projectname>assets\plugins\android
folder.
2.go <unityinstallationdirecory>\editor\data\playbackengines\androidplayer\apk
, copy androidmanifest.xml
file <projectname>assets\plugins\android
3.open both maintemplate.gradle
, androidmanifest.xml
file copied visual studio modification fix exporting project instruction above. skip/ignore step #1a , #1b. steps #2 #5. that's it.
this final maintemplate.gradle
should , this final androidmanifest.xml
should like. reference purposes. suggest you don't use mine instead follow copy steps above create yours because future unity versions can come different files. want make sure use latest 1 or may have problems building it.
4.build apk , see if works:
--
if reference count error gone, stop here:
5.getting error 1 below?
build failure release builds have signed when using gradle
just sign apk publishing settings in build settings. can create new keystore or use existing one.
6.another error below?
error: avoid hardcoding debug mode; leaving out allows debug , release builds automatically assign 1 [hardcodeddebugmode]
remove android:debuggable="true">
androidmanifest.xml
file.
if non exporting solution did not work have use exporting solution.
Comments
Post a Comment