Unity 2020 Mobile Game Development
上QQ阅读APP看书,第一时间看更新

Putting the project on your Android device

The following steps may be different for you depending on your Android version. If you are using Android Oreo or higher, start with step 5. If you have version 7 or lower, start at the beginning:

  1. On your Android device, you'll need to go to your Settings app.
  2. From there, scroll down till you get to the Security | Security & location section or similar, and then tap on it to go into the menu.
  1. Inside there, you'll see a section called Unknown sources, which you'll want to enable:

With this enabled, your device can now install the .apk file, but now you will need to move your game over to the device so that you can install it. The easiest way is to transfer it to your device via USB; we'll do that now.

For those of you who'd rather not use USB, I would suggest using a cloud storage app, such as Dropbox, to upload the  .apk file and then download it from the app and install that way. There's also another tool called ADB, which can send files to your phone via USB or WiFi. For more information on that and the rest of the Android build process, check out  https://docs.unity3d.com/Manual/android-BuildProcess.html.
  1. Connect your phone to your computer via USB. Upon being connected, your phone will show a notification saying that it's connected via USB for charging. Click on that notification and change the option to File Transfer:
  1. After that, go back to your computer and go into Windows Explorer/Finder, and then go to the Devices and Drives section; you should see your device appear there:
  1. Double-click on your device and access the internal shared storage section from there. Then, drag the .apk file we made before into this folder:
  1. Now, back in your phone, open the Files/File Explorer app. From there, click on the button on the right-hand side and select Show internal storage:
  1. Then, click on the button in the top-left corner and select your phone's name (in my case, Pixel 3a XL):
  1. From there, select your .apk file listed from the files included:
  1. You'll be asked to confirm the installation. Hit the Continue button:
  1. This will open up the installer. Go ahead and click on the Install button and wait for it to finish:
  1. You may see a window pop up that mentions that Play Protect doesn't recognize the developer. We will see how to solve this issue later on in Chapter 12, Game Build and Submission, but for now, click INSTALL ANYWAY and wait for the installation to finish:
Of course, I can't note the steps for all devices as some have different drivers that are required or additional steps that need to be performed in order to open files on the device. If these steps do not work and you do not know how to get files onto your device and access them and add new ones to them, go ahead and search for phone name file transfer, replacing the phone name with your phone's name.
  1. Once it's finished, go ahead and click on the Open button to open our game:

As you can see, the game is on there and it's working. Granted, you can't control it yet, and there are a lot of new things that you can't do, but this lets you know that you've set up your Android device properly. Now that you have your game on an Android device, you now need to get it working on iOS, which we will cover in the next section.