Skip to content

Build for Android

Marcus Hudritsch edited this page Jun 27, 2024 · 44 revisions

Requirements

Building and Running

  1. Clone the Git repository into a directory of your choice.
  2. Open Android Studio.
  3. Install the Android SDK using the Android Studio Setup Wizard dialog that opens up.
    • You can just leave the default options in the SDK Components Setup screen.
  4. In the Welcome to Android Studio dialog, click Open.
  5. Select the directory <SLProject root directory>/apps/source/platforms/android/example_project/ and click OK.
  6. Go to Tools > SDK Manager > SDK Tools:
    • Make sure the checkboxes NDK (Side by side) > 21.4.7075529 and Google USB driver are enabled and click OK.
    • Make sure that cmake 3.22.1 is installed.
  7. Plug in your Android device and allow USB debugging for this computer.
  8. Select your device as the running device in the top bar.
  9. Build the project by pressing the hammer button or choosing Build > Make Module 'exampleproject.app'.
    • By this, you are building the app_demo_slproject app.
    • SLProject cannot be built for architectures other than arm64-v8a because we only provide library prebuilts for this architecture.
    • This also means that SLProject doesn't run on x86 Android emulators.
  10. After a successful build, click on the green start button to install and launch the app on your device.

Building a Different App

  1. Go to File > Settings... > Build, Execution, Deployment > Gradle-Android Compiler. On Macs the settings are under Android Studio > Settings....
  2. Set Command-line Options to -PappLibraryName=<Name of your app>.
    • To build the node demo, enter -PappLibraryName=app-Demo-Node.
    • To build the example app from the guide to creating a new app, enter -PappLibraryName=app-Example.
  3. Build and start again.

Creating a Release Build

  1. On the left-hand side, switch to the Build Variants tab.
  2. Set the Active Build Variant to release.
  3. In the build.gradle file, set signingConfigs to the password of the SLProject keystore.
    signingConfigs {
        release {
            keyAlias 'slproject-release-key'
            keyPassword '....' // Change to your key password
            storeFile file('../slproject-release-key')
            storePassword '....' // Change to your store password
        }
    }
    
  4. Choose Build > Build bundle > Build APK.
  5. Create your keystore: If you don't have access to the SLProject keystore password, generate a new keystore and update the build.gradle file.
    1. Choose Build > Generate Signed Bundle or APK and select APK.
      1. Create or choose a signed keystone file in a secure file location.
      2. Fill in the Key store password, Key alias and Key password and click Next.
      3. Choose release and press Create. The APK gets signed and written to the destination folder.
    2. Then modify the build.gradle file to use your keystore with the provided password.