Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 2020 Mobile Game Development

You're reading from   Unity 2020 Mobile Game Development Discover practical techniques and examples to create and deliver engaging games for Android and iOS

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781838987336
Length 464 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John P. Doran John P. Doran
Author Profile Icon John P. Doran
John P. Doran
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Building Your Game 2. Project Setup for Android and iOS Development FREE CHAPTER 3. Mobile Input/Touch Controls 4. Resolution-Independent UI 5. Advertising Using Unity Ads 6. Implementing In-App Purchases 7. Getting Social 8. Keeping Players Involved with Notifications 9. Using Unity Analytics 10. Making Your Title Juicy 11. Game Build and Submission 12. Augmented Reality 13. Other Books You May Enjoy

Exporting a project for Android

Now that we have all of the setup done, we can open Unity with our project and export it for Android devices. In this section, we will first check whether we have Android Build Support installed, and then we will update the build and player settings to export our project. So, let's get started.

Installing Android Build Support for Unity

First of all, if you haven't done so already, you'll need to have selected to add Android Build Support as an option when you are installing Unity. If you have installed it, you can skip this section. If you did not install it when doing the initial installation, that is what we will cover in the following steps:

  1. Close the Unity Editor and then open up the Unity Hub and select the Installs section.
  2. From there, click on the three dots to the right of your current version of Unity and select the Add Modules option:
  1. Check the Android Build Support option, which should also check the Android SDK and NDK Tools and OpenJDK options. Afterward, click on the NEXT button:
  1. You'll be brought to a license terms page. Read it over and if you agree to it, check the agreement box and click on the DONE button:
  1. Wait for it to finish installing. Once finished, you should see the Android logo at the bottom of your install:

This means that Android Build Support has now been added to our version of Unity and we can build projects there. Next, we will see how to actually build the project for Android and the settings required to do so.

Updating build and player settings for Android projects

Now that we have Android support, let's open up our project again and change the platform we are developing for:

  1. At this point, we will dive into Unity and move into our Build Settings menu once again by going to File | Build Settings.
  1. Click on the Android option from the Platform list and then click on the Switch Platform button to make the change:

Note that this will make Unity reimport all of the assets in our game, so this may be time-consuming when you start to build larger projects. Once completed, you should notice that the Unity logo is now next to the Android option, signifying that's the platform to be built for:

  1. Now, in order to be able to build our project, we must set the bundle identifier for our game, which is a string that identifies the app. It's written like a URL in reverse, for example, com.yourCompanyName.yourGameName. To modify this, we'll need to open up the Player Settings menu, which we can get to by clicking on the Player Settings... button in the bottom-left part of the Build Settings menu or by going into Edit | Project Settings | Player. You'll note that the menu shows up as a new window:

Now that we're in Android mode (note the text on the title bar of the Unity Editor), we can change these properties:

  1. We'll discuss more of these in a later chapter, but for now, scroll down until you get to the Other Settings option, and from there, you'll see the Package Name property. We will change this to something else; for example, I used com.JohnPDoran.MobileDev. There's also a Minimum API Level option; make sure that your option is set to the same version as your phone or earlier, depending on what you want to support. Note that the earlier you go, the fewer things you'll have access to, but your project will be able to support more phones:
  1. Close the Project Settings window and open up the Build Settings menu again by going to File | Build Settings. Now, we can try to build the project by clicking on the Build button, saving it in the same Export folder we created earlier. It will ask for the name you'd like the file to have. I will use MobileDev as we did previously, because instead of a .exe file, it will be creating a .apk file:

Wait a bit, and once it's finished, you should have a new .apk file located in the folder. Of course, just having the APK file doesn't do much if we can't put it on our actual phone; so, in the next section, we will enable our phone to test the game on our device.

You have been reading a chapter from
Unity 2020 Mobile Game Development - Second Edition
Published in: Aug 2020
Publisher: Packt
ISBN-13: 9781838987336
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image