|
1 |
| -Please read the [general build guide](BUILD.md) for information on building other platform. Only Android specific instructions are found in this file. |
| 1 | +Please read the [general build guide](BUILD.md) for information on building other platforms. Only Android specific instructions are found in this file. **Note that these instructions apply to building for Oculus Quest.** |
2 | 2 |
|
3 | 3 | # Dependencies
|
4 | 4 |
|
5 |
| -Building is currently supported on OSX, Windows and Linux platforms, but developers intending to do work on the library dependencies are strongly urged to use 64 bit Linux as a build platform |
| 5 | +Building is currently supported on Windows, OSX and Linux, but developers intending to do work on the library dependencies are strongly urged to use 64 bit Linux as a build platform. |
6 | 6 |
|
7 |
| -You will need the following tools to build Android targets. |
| 7 | +### OS specific dependencies |
8 | 8 |
|
9 |
| -* [Android Studio](https://developer.android.com/studio/index.html) |
| 9 | +Please install the dependencies for your OS using the [Windows](BUILD_WIN.md), [OSX](BUILD_OSX.md) or [Linux](BUILD_LINUX.md) build instructions before attempting to build for Android. |
10 | 10 |
|
11 | 11 | ### Android Studio
|
12 | 12 |
|
13 |
| -Download the Android Studio installer and run it. Once installed, at the welcome screen, click configure in the lower right corner and select SDK manager |
| 13 | +Download the [Android Studio](https://developer.android.com/studio/index.html) installer and run it. Once installed, at the welcome screen, click _Configure_ in the lower right corner and select _SDK Manager_. |
14 | 14 |
|
15 |
| -From the SDK Platforms tab, select API levels 24 and 26. |
| 15 | +From the _SDK Platforms_ tab, select API levels 26 and 28. |
16 | 16 |
|
17 |
| -From the SDK Tools tab select the following |
| 17 | +From the _SDK Tools_ tab, select the following |
18 | 18 |
|
19 | 19 | * Android SDK Build-Tools
|
20 | 20 | * GPU Debugging Tools
|
21 |
| -* CMake (even if you have a separate CMake installation) |
22 | 21 | * LLDB
|
23 | 22 | * Android SDK Platform-Tools
|
24 | 23 | * Android SDK Tools
|
25 | 24 | * NDK (even if you have the NDK installed separately)
|
26 | 25 |
|
27 |
| -Make sure the NDK installed version is 18 (or higher) |
| 26 | +Still in the _SDK Tools_ tab, click _Show Package Details_. Select CMake 3.6.4. Do this even if you have a separate CMake installation. |
28 | 27 |
|
29 |
| -# Environment |
| 28 | +Also, make sure the NDK installed version is 18 (or higher). |
30 | 29 |
|
31 |
| -Setting up the environment for android builds requires some additional steps |
| 30 | +# Environment |
32 | 31 |
|
33 |
| -#### Set up machine specific Gradle properties |
| 32 | +### Create a keystore in Android Studio |
| 33 | +Follow the directions [here](https://developer.android.com/studio/publish/app-signing#generate-key) to create a keystore file. You can save it anywhere (preferably not in the `hifi` folder). |
34 | 34 |
|
35 |
| -Create a `gradle.properties` file in $HOME/.gradle. Edit the file to contain the following |
| 35 | +### Set up machine specific Gradle properties |
| 36 | + |
| 37 | +Create a `gradle.properties` file in the `.gradle` folder (`$HOME/.gradle` on Unix, `Users/<yourname>/.gradle` on Windows). Edit the file to contain the following |
36 | 38 |
|
37 | 39 | HIFI_ANDROID_PRECOMPILED=<your_home_directory>/Android/hifi_externals
|
| 40 | + HIFI_ANDROID_KEYSTORE=<key_store_directory>/<keystore_name>.jks |
| 41 | + HIFI_ANDROID_KEYSTORE_PASSWORD=<password> |
| 42 | + HIFI_ANDROID_KEY_ALIAS=<key_alias> |
| 43 | + HIFI_ANDROID_KEY_PASSWORD=<key_passwords> |
| 44 | + |
| 45 | +Note, do not use $HOME for the path. It must be a fully qualified path name. Also, be sure to use forward slashes in your path. |
38 | 46 |
|
39 |
| -Note, do not use `$HOME` for the path. It must be a fully qualified path name. |
| 47 | +#### If you are building for an Android phone |
40 | 48 |
|
41 |
| -### Setup the repository |
| 49 | +Add these lines to `gradle.properties` |
42 | 50 |
|
43 |
| -Clone the repository |
| 51 | + SUPPRESS_QUEST_INTERFACE |
| 52 | + SUPPRESS_QUEST_FRAME_PLAYER |
44 | 53 |
|
45 |
| -`git clone https://github.com/highfidelity/hifi.git` |
| 54 | +#### If you are building for an Oculus Quest |
46 | 55 |
|
47 |
| -Enter the repository `android` directory |
| 56 | +Add these lines to `gradle.properties` |
48 | 57 |
|
49 |
| -`cd hifi/android` |
| 58 | + SUPPRESS_INTERFACE |
| 59 | + SUPPRESS_FRAME_PLAYER |
50 | 60 |
|
51 |
| -Execute two gradle pre-build steps. This steps should only need to be done once, unless you're working on the Android dependencies |
| 61 | +The above code to suppress modules is not necessary, but will speed up the build process. |
52 | 62 |
|
53 |
| -`./gradlew extractDependencies` |
| 63 | +### Clone the repository |
54 | 64 |
|
55 |
| -`./gradlew setupDependencies` |
| 65 | +`git clone https://github.com/highfidelity/hifi.git ` |
56 | 66 |
|
57 | 67 | # Building & Running
|
58 | 68 |
|
| 69 | +### Building Modules |
| 70 | + |
59 | 71 | * Open Android Studio
|
60 |
| -* Choose _Open Existing Android Studio Project_ |
| 72 | +* Choose _Open an existing Android Studio project_ |
61 | 73 | * Navigate to the `hifi` repository and choose the `android` folder and select _OK_
|
| 74 | +* Wait for Gradle to sync (this should take around 20 minutes the first time) |
62 | 75 | * From the _Build_ menu select _Make Project_
|
63 |
| -* Once the build completes, from the _Run_ menu select _Run App_ |
64 | 76 |
|
| 77 | +### Running a Module |
| 78 | + |
| 79 | +* In the toolbar at the top of Android Studio, next to the green hammer icon, you should see a dropdown menu. |
| 80 | +* You may already see a configuration for the module you are trying to build. If so, select it. |
| 81 | +* Otherwise, select _Edit Configurations_. |
| 82 | + |
| 83 | +Your configuration should be as follows |
| 84 | + |
| 85 | +* Type: Android App |
| 86 | +* Module: <your module> (you probably want `interface` or `questInterface`) |
| 87 | + |
| 88 | +For the interface modules, you also need to select the activity to launch. |
| 89 | + |
| 90 | +#### For the Android phone interface |
| 91 | + |
| 92 | +* From the _Launch_ drop down menu, select _Specified Activity_ |
| 93 | +* In the _Activity_ field directly below, put `io.highfidelity.hifiinterface.PermissionChecker` |
| 94 | + |
| 95 | +#### For the Oculus Quest interface |
| 96 | + |
| 97 | +* From the _Launch_ drop down menu, select _Specified Activity_ |
| 98 | +* In the _Activity_ field directly below, put `io.highfidelity.questInterface.PermissionsChecker` |
| 99 | + |
| 100 | +Note the 's' in Permission**s**Checker for the Quest. |
| 101 | + |
| 102 | +Now you are able to run your module! Click the green play button in the top toolbar of Android Studio |
| 103 | +r |
| 104 | +# Troubleshooting |
| 105 | + |
| 106 | +To view a more complete debug log, |
| 107 | + |
| 108 | +* Click the icon with the two overlapping squares in the upper left corner of the tab where the sync is running (hover text says _Toggle view_) |
| 109 | +* To change verbosity, click _File > Settings_. Under _Build, Execution, Deployment > Compiler_ you can add command-line flags, as per Gradle documentation |
| 110 | + |
| 111 | +Some things you can try if you want to do a clean build |
| 112 | + |
| 113 | +* Delete the `build` and `.externalNativeBuild` folders from the folder for each module you're building (for example, `hifi/android/apps/interface`) |
| 114 | +* If you have set your `HIFI_VCPKG_ROOT` environment variable, delete the contents of that directory; otherwise, delete `AppData/Local/Temp/hifi` |
| 115 | +* In Android Studio, click _File > Invalidate Caches / Restart_ and select _Invalidate and Restart_ |
| 116 | + |
| 117 | +If you see lots of "couldn't acquire lock" errors, |
| 118 | +* Open Task Manager and close any running Clang / Gradle processes |
0 commit comments