- Prerequisites
- Simple setup
- To compile and run an existing sample application
- To compile and run an existing GLES2 sample application
- To create a new GLES2 demo project named 'CoolNewDemo'
- Using android studio
- Command line arguments
- Linux notes
-
IMPORTANT! The way gradle currently handles CMake builds on windows place some serious limits on the path length, so its recommended to either place the DemoFramework folder close to the root of the drive or to set the environment variable FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR to a directory close to the root of the drive.
-
- Make sure to configure JAVA_HOME to point to the JDK directory.
- Using the 32bit sdk might give you build memory issues.
-
Once its installed its a good idea to run "SDK Manager.exe" and make sure everything is up to date.
IMPORTANT!
- Android studio must be at least 4.1.2
- Get the android studio full package and enable the default packages.
- Configure the SDK manager
- "SDK Platforms" add if necessary "Android 12.0" which is SDK 31!
- "SDK Tools" add if necessary "CMake, LLDB, NDK, Android Support Repository"
- Make sure to configure ANDROID_HOME to point to the android sdk directory
- Make sure to configure ANDROID_NDK to point to the android ndk directory
- Make sure you have at least android-ndk-r25b.
- We recommend the latest LTS which currently is NDK r25b.
-
To be able run python scripts, they are needed to build.
-
Download the source from git.
It's also a good idea to read the introduction to the FslBuild toolchain
Android projects are generated to the path specified in the environment variable FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR. If it's not defined the 'prepare' script sets it to a default location.
- Start a windows console (cmd.exe) in the DemoFramework folder
- Run the
prepare.bat
file located in the root of the framework folder to configure the necessary environment variables and paths. Please beware that theprepare.bat
file requires the current working directory to be the root of your demoframework folder to function (which is also the folder it resides in).
The general approach will be:
-
Make sure that you performed the simple setup, including the API's the sample need.
-
Change directory to the sample directory:
cd DemoApps/<MAIN-API-NAME>/<SAMPLE-NAME>
Example MAIN-API-NAME's: GLES2, GLES3, OpenCL, Vulkan.
Type
dir
to see the dir choice.Example SAMPLE-NAME's: Bloom, S06_Texturing.
Type
dir
after entering a API folder to see the list of samples -
Build the application
FslBuild.py -p android
If you want to save a bit of compilation time you can build for the ANDROID ABI you need by adding
FslBuild.py -p android --Variants [ANDROID_ABI=armeabi-v7a]
The following commands are also pretty useful to know.
Command | Description |
---|---|
FslBuildGen.py -p android |
Generate the project which can then be opened in gradle |
FslBuild.py -p android --ListVariants |
List all the build variants that can be specified. This is useful to see the ANDROID_ABI's. |
FslBuildInfo.py -p android --ListRequirements |
To list the samples requirements. |
It is also recommended to check out the README.md
and Example.jpg
that is included with all samples.
Note:
If you add source files to a project or change the Fsl.gen file then run the
FslBuildGen.py
script in the project root folder to regenerate the various
build files or just make sure you always use the FslBuild.py
script as it
automatically adds files and regenerate build files as needed.
In this example we will utilize the GLES2.S06_Texturing app.
-
Make sure that you performed the simple setup
-
Change directory to the sample directory:
cd DemoApps\GLES2\S06_Texturing
-
Build a app for Android using gradle + cmake
FslBuild.py -p android
-
Make sure that you performed the simple setup
-
Change directory to the GLES2 sample directory:
cd DemoApps/GLES2
-
Create the project template using the FslBuildNew.py script
FslBuildNew.py GLES2 CoolNewDemo
-
Change directory to the newly created project folder 'CoolNewDemo'
cd CoolNewDemo
-
Build a app for Android using gradle + cmake
FslBuild.py -p android
If you just want to regenerate the cmake build files then you can just run
FslBuildGen.py -p android
If you want to save a bit of compilation time you can build for the ANDROID ABI you need by adding
FslBuildGen.py -p android --Variants [ANDROID_ABI=armeabi-v7a]
or
FslBuild.py -p android --Variants [ANDROID_ABI=armeabi-v7a]
- Follow the instructions for "creating a new project" or "building an existing project".
- As projects are generated to the path specified by the FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR environment variable you can locate the project there and open it with android studio. Be sure to open Android studio in a correctly configured environment. Here it could be a good idea to create a script for launching android studio with the right environment.
If you add source files to a project or change the Fsl.gen file then run the FslBuildGen.py script in the project root folder to regenerate the various build files.
Android Studio->Run->Edit Configurations->App->Launch Flags:
Add the arguments using -e "args" "<arguments>"
-e "args" "--DensityDpi 160 -vvvv"
Add the arguments using -e "args" "<arguments>"
-e "args" "--DensityDpi 160 -vvvv"
Install for private user
Unzip android studio like this:
sudo unzip android-studio-ide_FILENAME.zip -d ~/sdk
cd ~/sdk/android-studio/bin
./studio.sh
In the UI make sure to install the sdk in a directory you have access to for example
~/sdk/android-sdk-linux