- Home /
Android questions: multi-dex and default activity
Hello everybody,
The project that I am working on has surpassed the 65536 limit for field references when I try to build for Android and will no longer build. I get a message in the console log that tells me to try to use the --multi-dex option. From what I can gather googling around, in order to deal with this I need to generate an Android Studio project and build the project from in there.
So I did generate an android studio project by selecting "Google Android Project" from the build menu. I was able to successfully import this project into Android Studio. I did not change any of the default options when I imported the project.
My project has several modules in it. The main module for the game I'm making is called is called Frontline.
When I go to run my project, I have to go to "Run/Edit Configurations..." Here I create a new Android Application by clicking on the + button. In the right hand panel under the General tab, there a drop down called "Module:" The only module I can select from this drop down is "Frontline" This so far is great.
However, there is no Default Activity. I think to myself that I can work around this by choosing "Specified Activity" from the "Launch:" drop down. I then click the ... button beside the "Activity:" text entry box. A dialog box pops up and I am able to navigate to my Frontline project and select UnityPlayerActivity. I am then returned to the Run/Debug Configuration dialog where there is an error listed at the bottom of the dialog that says "Warning: The activity 'UnityPlayerActivity' is not declared in AndroidManifest.xml'
I think I have an idea what this means, but I don't know how to deal with this. In my project, there are several module. The first module is called "AN_Res". The second is called "appcompat". The third is called "cardview" etc. Each has an AndroidManifest.xml
The AndroidManifest.xml for the "Frontline" project lists the activity I want to run. I think that the manifest that the project is trying to use is the manifest for "AN_Res". The reason that I believe this is that there are some error messages relating to @drawable/app_icon and @string/app_name which are referenced in that manifest.
Until I hit the 65536 limit, I could build in Unity and deploy to my device with no issues. Why does importing into Android Studio with everything set to the default not give me a project that will run? What do I have to do to get around these problems that I am having with the default activity.
Any information would be greatly appreciated.
Thank You John Lawrie
And for reference, he is a snippet of the console log that I get when I try to build and deploy to my android device in Unity.
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. C:\Program Files\Java\jdk1.8.0_91\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/john/AppData/Local/Android/android-sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
trouble writing output: Too many field references: 85070; max is 65536. You may try using --multi-dex option. References by package: 3 android.accounts 29 android.app 4 android.content etc.. etc...
Your answer
Follow this Question
Related Questions
sound paused in android multiple Activities 0 Answers
Pass an image from Android activity to unity 0 Answers
Android and Unity - creating a transparent Activity 1 Answer
how to integrate 2 unity activity within 1 android app 0 Answers
How to make an Android activity overlay to current screen? 0 Answers