• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dalanchoo · Aug 16, 2016 at 05:00 AM · androidactivity

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...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Close unity activity and start another activity - android 0 Answers

How can I replace correctly the main activity on the Android Manifest? 0 Answers

Android Custom Activity -1 Answers

Android - Non main activity plugin not working: Class Not Found Exception 1 Answer

android: why scene goes black when showing new activity? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges