Layout
Содержание:
Recommended Setup
You should make sure that the Unreal Editor and the Epic Games Launcher are both closed to ensure that there are no problems with either the installation of NDK components or setting your environment variables for the engine.
If you are moving to Unreal 4.25 from 4.24 or earlier, we recommend that you uninstall CodeWorks for Android and any existing NDK components, and delete the folder CodeWorks was installed to. Otherwise, Android Studio will continue to use the previous CodeWorks installation folder for SDK updates.
The default installation directory for CodeWorks is C:/NVPACK. Make sure this folder is deleted when you finish uninstalling CodeWorks.
If you need to support an earlier installation of Unreal Engine while also maintaining an installation of Unreal 4.25 or later, refer to the sections on
and
below.
All the Android splits
- Activities: Start activities with minimal boilerplate.
- Alert Dialog: Create simple alert dialogs with simple code.
-
Alert Dialog AppCompat: AppCompat version of
Alert Dialog. -
Alert Dialog AppCompat Coroutines:
extension functions for AppCompat AlertDialog. - App Context: Always have your application at hand with .
-
Arch Lifecycle: Extensions to get s, use and
observe s. -
Arch Room: Room helpers to instantiate your DB and perform
transactions in Kotlin. -
Bundle: to use with property syntax for
extras and more. -
Checked Lazy: that checks property access on
main thread, and to make your own variant. -
Dimensions: Android extensions for and .
Particularly handy when using Views DSL. -
Exceptions: , and similar
functions that return . -
Fragments: Start activities from fragments and do transactions with
minimal boilerplate. -
Fragment Args: Fragment arguments without ceremony thanks to
delegated properties. -
Init Provider: Base class for s used for automatic
initialization purposes. -
Intents: Transform s into powerful typesafe intent specs,
and create s the clean and easy way. -
Main Handler: Top-level property to stop allocating multiple
s for main . - Main Thread: Properties and precondition checkers related to Android main thread.
- Permissions: Request runtime permissions without polluting your codebase.
- Preferences: Property syntax for Android’s SharedPreferences.
-
Resources: Extensions to get resources like strings, colors or drawables easily,
with support for themed attributes. -
Selectable Views: Selectable Views with property before
API 23. -
Selectable Views AppCompat: Selectable Views
for AppCompatTextView. -
Selectable Views ConstraintLayout:
Selectable Views for ConstraintLayout. - Snackbar: Grab a snack without ceremony with and .
-
Stetho init: Have Stetho for your debug
builds, without writing any code! -
System Services: No more
. - Toast: Show a toast by just calling , and dodge .
-
Typesafe RecyclerView: Typesafe and for
easy basic usage of . - Views: Extensions function and properties on s.
-
Views AppCompat: AppCompat extension of Views. Includes helpers
for tinting, and tooltip. -
Views CardView: CardView extension of Views. Provides a
property. - Views Coroutines: Android Views + Kotlin coroutines.
- Views Coroutines Material: Material Components + Kotlin coroutines.
- Views DSL: Create UIs with readable Kotlin code.
- Views DSL AppCompat: AppCompat extension of Views DSL.
-
Views DSL ConstraintLayout: ConstraintLayout extension of
Views DSL. -
Views DSL CoordinatorLayout: CoordinatorLayout extension of
Views DSL. - Views DSL IDE preview: Preview Views DSL UIs in the IDE.
- Views DSL Material: Material Components extension of Views DSL.
- Views DSL RecyclerView: RecyclerView extension of Views DSL.
- Views Material: Material Components extension of Views.
- Views RecyclerView: RecyclerView extension of Views.
Other Resources
This doc gives a high level overview of the NDK’s build, packaging, and test
process. For other use cases, or more in depth documentation, refer to the
following sources:
- Adding a new NDK API or platform version? Check Generating Sysroots.
- Working on Clang or GCC? See Toolchains.md.
- File bugs against the NDK at https://github.com/android-ndk/ndk/issues.
Building the NDK
Both Linux and Windows host binaries are built on Linux machines. Windows host
binaries are built via MinGW cross compiler. Systems without a working MinGW
compiler can use to generate their own
and be added to the for build scripts to discover.
Building binaries for Mac OS X requires at least 10.8.
Target headers and binaries are built on Linux.
Improve this library
If you want this library to have a new feature or an improvement in a
new or in an existing module, please, open an issue or vote/comment a
similar one first, so it can be discussed.
Documentation contributions are also welcome.
For typos or other small improvements, feel free to submit a PR
(pull request) directly.
For more significant doc contributions, please, open an issue first so it
can be discussed.
If you find a bug, please open an issue with all the important details.
If you know a simple fix that is not API breaking and that does not have
side-effects that need to be considered, you may also directly submit a PR.
Uploading symbols
Note
The App Center Build and Distribution service can automatically forward symbols to the Diagnostics service. If you use App Center to build and auto distribute your app to your end users, you don’t need to manually obtain and upload the symbol files as detailed in the steps below.
App Center Portal
- Log into App Center and select your app.
- In the left menu, navigate to the Diagnostics section, then Issues.
- If your application hasn’t reported any crash yet, you’ll need to use the API or CLI to upload Breakpad symbols.
- If your application already has reported crashes that need symbols, check the Unsymbolicated tab and there should be a version group with missing symbols, click on it to reveal the menu to upload the file.
- After the symbols are indexed by App Center, crashes will be symbolicated for you.
App Center API
The process for uploading symbols through the API involves a series of three API calls: one to allocate space on our backend, one to upload the file, and one to update the status of the upload. The body of the first API call should set to .
- Trigger a request to the .
This call allocates space on our backend for your file and returns a and an property.
- Using the property returned from the first step, make a request with the header: and supply the location of your file on disk. This call uploads the file to our backend storage accounts. Learn more about .
- Make a request to the using the property returned from the first step. In the body of the request, specify whether you want to set the status of the upload to (successfully completed) the upload process, or (unsuccessfully completed).
Note
The symbol uploads API does not work for files that are larger than 256MB. Please use the App Center CLI to upload these files. You can install the App Center CLI by following the instructions in our App Center CLI repo.
Setting Up Unreal to Use Android NDK r21b
-
Navigate to your Unreal Engine 4 install directory � for example, C:/Program Files/Epic Games/UE_4.25.
-
Open Engine/Extras/Android.
-
Inside this directory, run the SetupAndroid script appropriate for your operating system. SetupAndroid.bat is for Windows, SetupAndroid.command is for Mac, and SetupAndroid.sh is for Linux.
Click image for full size.
-
You will be prompted to accept the Android SDK license agreement. Type Y and press Enter to accept.
Click image for full size.
-
When the installation completes, press any key to dismiss the command prompt and finish the process.
This script will download and install NDK r21b for you in your Android home directory. The install directory for NDK should be C:/Users//AppData/Local/Android/SDK/ndk/, where «username» is your login name for your computer. You should see a folder containing NDK r21b.
In the event that you receive an error stating that cannot be loaded, navigate to the folder where it is expected (usually ) and create an empty file. Android setup should then proceed normally.
If you receive an error stating that a package called could not be loaded, open the SetupAndroid script with a text editor, and locate the line of code that reads:
Remove the entry in this list for , but leave the others. This will enable setup to run normally. This issue is addressed in 4.25.1.
Components
The NDK components can be loosely grouped into host toolchains, target prebuilts, build systems, and support libraries.
Host Toolchains
-
contains GCC and Clang toolchains.
- contains ARCH and ABIS this toolchain can handle.
- contains toolchain-specific default CFLAGS/LDFLAGS when this toolchain is used.
-
contains build dependencies and additional tools.
- make, python, yasm, and for Windows: cmp.exe and echo.exe
- and can also be found here.
Target Prebuilts
- contains the headers for the NDK. See Unified Headers for more information.
- contains stub shared libraries and a few static libraries for each API level. See Platform APIs for more information.
- contains the headers and libraries for the various C++ STLs.
- contains gdbserver.
Build Systems
- contains ndk-build, the NDK’s home grown build system. Most of the implementation lives in .
- contains components for using the NDK with CMake (at present only a CMake toolchain file, but in the future it will contain CMake modules that CMake will load, obviating the need for a toolchain file).
- contains , but also contains legacy sripts that were used to build the NDK. Eventually, this should contain nothing but the standalone toolchain scripts.
- The gradle plugins for the NDK are not included in the NDK.
Support Libraries
sources/android and sources/third_party contain modules that can be used in apps (gtest, cpufeatures, native_app_glue, etc) via $(call import-module,$MODULE).
Prerequisites
-
AOSP NDK Repository
Check out the branch master-ndk
repo init -u https://android.googlesource.com/platform/manifest \
-b master-ndk# Googlers, use
repo init -u \
persistent-https://android.git.corp.google.com/platform/manifest \
-b master-ndk
Linux dependencies are listed in the Dockerfile. You can use docker to build the NDK:
docker build -t ndk-dev infradocker docker run -it -u $UID -v `realpath ..`:/src -w srcndk ndk-dev checkbuild.py
Building on Mac OS X has similar dependencies as Linux, but also requires Xcode.
Running tests requires that is in your . This is provided as part of the .
Components
The NDK consists of three parts: host binaries, target prebuilts, and others
(build system, docs, samples, tests).
Host Binaries
-
contains GCC and Clang toolchains.
- contains ARCH and ABIS this toolchain can handle.
-
contains toolchain-specific default CFLAGS/LDFLAGS
when this toolchain is used.
-
contains build dependencies and additional tools.
- make, awk, python, yasm, and for Windows: cmp.exe and echo.exe
- , and can also be found here.
Target Headers and Binaries
-
contains headers and libraries
for each API level. -
contains the headers and libraries for the various C++
STLs. - contains gdbserver.
Others
- contains the ndk-build system and scripts to rebuild NDK.
-
and contain modules that can be used
in apps (cpufeatures, native_app_glue, etc) via
What is a split
A «split» is a module of the Splitties library that you can add as a
dependency. It only includes the required transitive dependencies.
This allows you to only add what you need in your app or library module,
so the final apk is as small as possible and doesn’t include stuff not used
by your app.
Let’s say you’re build a Wear OS app using the Views DSL.
Wear OS apps don’t need AppCompat. Including it would be a waste of
bandwidth and storage. The Views DSL core module relies on the Android
SDK but not on AppCompat, so you don’t bloat your wrist app with AppCompat
by using Views DSL. However, if you are building a phone, tablet or computer
Android app, there’s a Views DSL AppCompat split with a few extensions for
you to use.
Installing Android Studio
Before setting up the required SDK and NDK components on your computer, you need to install Android Studio version 3.5.3.
-
Navigate to the Android Studio Archive
in your web browser. Scroll down to Android Studio 3.5.3, click to unfold the dropdown, and download the appropriate installer or zip file for your operating system.Click image for full size.
-
Run the Android Studio installer. In the Welcome to Android Studio Setup dialog, click Next to continue.
Click image for full size.
-
In the Choose Components dialog, click Next to continue. You can leave the default components enabled.
Click image for full size.
-
In the Configuration Settings dialog, select an appropriate install location and click Next to continue. We recommend using the default location.
Click image for full size.
-
In the Choose Start Menu Folder, click Install to begin the installation process.
Click image for full size.
-
When the installation finishes, click Next to begin setting up components.
Click image for full size.
-
When setup completes, make sure the Start Android Studio box is checked and click Finish to exit the installer.
Unsymbolicated crashes
Unsymbolicated crashes are displayed in the App Center Diagnostics section so you can view some details even before uploading symbols. The missing symbols from these crashes will be shown in the «unsymbolicated» tab. If the missing symbols are uploaded, the unsymbolicated crash group will be replaced by a symbolicated crash group.
Note
App Center doesn’t support symbolication of frames which come from system libraries.
Given the high fragmentation of system binaries for Android and other platforms – which might be different on any given device/OS version combination – App Center does not provide symbols itself for system binaries and automatically skips frames from system binaries in symbolication.
When layouts other s
George MountFollow
Jun 29, 2016 · 2 min read
In the last article you saw how easy it is to avoid using findViewById with Android Studio 1.5 and higher. This is essentially the View Holder pattern as described here:
I showed how to use Android Studio to generate a class that acts as a View Holder for a single layout file, but what about included layouts? What about merged included layouts?
It turns out that those are also supported, but each layout file generates a different class. Here is an example:
hello_world.xml<layout xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/hello" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <include android:id="@+id/included" layout="@layout/included_layout"/> </LinearLayout></layout>included_layout.xml<?xml version="1.0" encoding="utf-8"?><layout xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/world"/></layout>
You would access the two different TextViews this way:
HelloWorldBinding binding = HelloWorldBinding.inflate(getLayoutInflater());binding.hello.setText(“Hello”);binding.included.world.setText(“World”);
The pattern for included files follows the same pattern as for Views: the ID of the <include> tag is used as its field name in the class. The included layout has generated its own class with its own fields for the Views in its layout. Any IDs that are shared between different layout can be easily distinguished by the developer. For example, if you include the same layout twice:
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/hello" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <include android:id="@+id/world1" layout="@layout/included_layout"/> <include android:id="@+id/world2" layout="@layout/included_layout"/> </LinearLayout></layout>
The two “world” TextViews can be accessed easily:
HelloWorldBinding binding = HelloWorldBinding.inflate(getLayoutInflater());binding.hello.setText(“Hello”);binding.world1.world.setText(“First World”);binding.world2.world.setText(“Second World”);
Remember to give the include tag an ID or no public field will be given to it. Also, remember to use the outer <layout> for layouts that you want to have fields generated. This triggers the preprocessing step that allows it to associate the Views with the fields and generate a class.
Setting Up Android Studio for First-Time Use
When you start your new install of Android Studio for the first time, follow these steps:
-
When the Import Android Studio Settings dialog appears, select do not import settings, then click OK to continue.
-
When the Data Sharing dialog appears, choose whether or not you want to send usage statistics to Google. This is an option you may choose at your discretion, and either choice will continue to the next step.
Click image for full size.
-
The Android Studio Setup Wizard will appear. Click Next to continue. If you are prompted for an update, click the X button to dismiss the prompt, as you need to specifically install version 3.5.3.
Click image for full size.
-
In the Install Type dialog, select Custom and click Next.
Click image for full size.
-
In the Select UI Theme dialog, choose your preferred theme and click Next.
Click image for full size.
-
In the Verify Settings dialog, click Finish to finalize your setup and begin downloading components.
Click image for full size.
-
When components are finished downloading, click Finish again to end setup.
Finalizing Android Studio Installation on Your OS
If you are on Windows, restart your computer.
If you are on Linux, close your terminal window and reopen it.
If you are on MacOS, you can either close your terminal window and reopen it, or log out and log back in.
Manually Targeting SDK Paths
If you followed the above how-to sections correctly, Unreal Engine will automatically associate the SDK paths for the Android SDK, the current Android NDK version, and the Java Development Kit (JDK). In the event that you need to manually target your SDK paths, you can find them by opening Edit > Project Settings, navigating to the Platforms > Android > Android SDK section.
When these fields are left blank, they fall back on a set of default paths used by the installation process in the previous sections. If you have multiple installations of these components, or have installed them in non-standard directories, you can manually provide their paths here. Alternatively, you can open DefaultEngine.ini and provide them under the section.
If the entries for , , and do not exist in your DefaultEngine.ini, they will use the default path to the Android home directory.