From 8838daac25ae1a7fe8dd369b36e8efb75f0c4a90 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 16:53:45 +0100 Subject: [PATCH 01/32] Code review comments. --- app/build.gradle.kts | 2 +- build.sh | 119 +++++++++++++++++++++++++++++++++---------- 2 files changed, 94 insertions(+), 27 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b9b81ac5..d2c20450 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -61,7 +61,7 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) - baselineProfile.automaticGenerationDuringBuild = true + baselineProfile.automaticGenerationDuringBuild = false configure { mappingFileUploadEnabled = true } diff --git a/build.sh b/build.sh index d0ebf9c7..43591224 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,113 @@ #!/usr/bin/env bash -# -# Copyright 2022 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# IGNORE this file, it's only used in the internal Google release process -# Fail on any error. +# Fail on any error to ensure the script stops if a step fails. set -e +# --- Configuration --- +# Get the script's directory. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -APP_OUT=$DIR/app/build/outputs + +# Define the Android SDK version you want to target. +ANDROID_SDK_VERSION="36" +ANDROID_BUILD_TOOLS_VERSION="34.0.0" + +# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). +# This system image is designed for headless, automated testing in CI environments +# and is more compatible with software rendering. It will be installed but may not +# be used by the new build command. +EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" + +# Define installation paths for local tools. +# These will be created within the project directory. +export ANDROID_HOME="$DIR/android_sdk" + + +# --- Environment Setup --- + +# Step 1: Check for essential command-line tools. +echo "INFO: Checking for prerequisites (wget, unzip, tar)..." +for cmd in wget unzip tar; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: Command '$cmd' not found. Please install it using your system's package manager (e.g., 'sudo apt-get install $cmd') and try again." + exit 1 + fi +done +echo "INFO: Prerequisites are installed." + + +# Step 2: Install and configure Java 17 system-wide. +echo "INFO: Setting up Java 17..." +# The build needs Java 17, set it as the default Java version. +sudo apt-get update +sudo apt-get install -y openjdk-17-jdk +sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java +echo "INFO: Verifying Java version..." +java -version + + +# Add the local SDK and emulator tools to the PATH for this session. +# The system-wide Java will already be in the PATH. +export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" +echo "INFO: Local tools added to PATH." + + +# Step 3: Download and set up the Android SDK. +if [ ! -d "$ANDROID_HOME/cmdline-tools" ]; then + echo "INFO: Android SDK not found. Setting it up now..." + + # The URL for the command-line tools can change. + # You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only + CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" + + echo "INFO: Downloading Android command-line tools..." + wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" + + # Unzip into a temporary directory first. + unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip + + # The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest + # The zip extracts to 'cmdline-tools', so we move its contents to the correct location. + mkdir -p "$ANDROID_HOME/cmdline-tools/latest" + mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" + + # Clean up temporary files. + rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip + + echo "INFO: Android command-line tools installed." +else + echo "INFO: Android SDK already found at '$ANDROID_HOME'." +fi + + +# Step 4: Accept licenses and install required SDK packages. +echo "INFO: Accepting SDK licenses..." +# The 'yes' command automatically pipes "y" to the license agreement prompts. +yes | sdkmanager --licenses > /dev/null + +echo "INFO: Installing Android SDK packages, including emulator and system image..." +sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" + + +# --- Build Process --- # This script assembles the release build of the Android application. # Ensure gradlew is executable chmod +x ./gradlew # Clean the project (optional, but good for a fresh release build) -echo "Cleaning the project..." +echo "INFO: Cleaning the project..." ./gradlew clean -# Assemble the release build -echo "Assembling the release build..." -./gradlew app:bundleRelease +# Build the production release bundle without generating a baseline profile. +echo "INFO: Building the production release bundle..." +./gradlew app:bundleRelease -x test -Pandroid.baselineProfile.automaticGenerationDuringBuild=false # Check if the build was successful if [ $? -eq 0 ]; then - echo "Build successful! The APK/AAB can be found in app/build/outputs/" + echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/prodRelease/" else - echo "Build failed. Please check the console output for errors." + echo "FAILURE: Build failed. Please check the console output for errors." exit 1 fi -exit 0 \ No newline at end of file +exit 0 From a467a3a6ff0b2180e237d24fe929d7d99ef98200 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 17:20:19 +0100 Subject: [PATCH 02/32] Fix presubmit to androidify build --- kokoro/gcp_ubuntu_docker/presubmit.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index 1b9d8a93..d9f93353 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -1 +1 @@ -build_file: "kokoro-codelab-riggaroo/kokoro/gcp_ubuntu_docker/kokoro_build.sh" \ No newline at end of file +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" \ No newline at end of file From 7e50eb601c299142b2f30a5034c5ab58ac3d4f61 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 17:35:42 +0100 Subject: [PATCH 03/32] Fix presubmit to androidify build --- build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 43591224..724d0d62 100755 --- a/build.sh +++ b/build.sh @@ -41,9 +41,11 @@ echo "INFO: Setting up Java 17..." sudo apt-get update sudo apt-get install -y openjdk-17-jdk sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java -echo "INFO: Verifying Java version..." java -version +# Also clear JAVA_HOME variable so java -version is used instead +export JAVA_HOME= + # Add the local SDK and emulator tools to the PATH for this session. # The system-wide Java will already be in the PATH. From f0838b63158224b9c31724d54057e3154a63a9b7 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 17:53:02 +0100 Subject: [PATCH 04/32] accept android sdk licenses --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 724d0d62..606069d0 100755 --- a/build.sh +++ b/build.sh @@ -84,7 +84,7 @@ fi # Step 4: Accept licenses and install required SDK packages. echo "INFO: Accepting SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. -yes | sdkmanager --licenses > /dev/null +echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses echo "INFO: Installing Android SDK packages, including emulator and system image..." sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" From 3c4124e856eebe2052714ba4a6d25d4b3427cc43 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 18:03:49 +0100 Subject: [PATCH 05/32] accept android sdk licenses --- build.sh | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/build.sh b/build.sh index 606069d0..4162c5c4 100755 --- a/build.sh +++ b/build.sh @@ -46,45 +46,12 @@ java -version # Also clear JAVA_HOME variable so java -version is used instead export JAVA_HOME= - -# Add the local SDK and emulator tools to the PATH for this session. -# The system-wide Java will already be in the PATH. -export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" -echo "INFO: Local tools added to PATH." - - -# Step 3: Download and set up the Android SDK. -if [ ! -d "$ANDROID_HOME/cmdline-tools" ]; then - echo "INFO: Android SDK not found. Setting it up now..." - - # The URL for the command-line tools can change. - # You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only - CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" - - echo "INFO: Downloading Android command-line tools..." - wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" - - # Unzip into a temporary directory first. - unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip - - # The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest - # The zip extracts to 'cmdline-tools', so we move its contents to the correct location. - mkdir -p "$ANDROID_HOME/cmdline-tools/latest" - mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" - - # Clean up temporary files. - rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip - - echo "INFO: Android command-line tools installed." -else - echo "INFO: Android SDK already found at '$ANDROID_HOME'." -fi - - -# Step 4: Accept licenses and install required SDK packages. echo "INFO: Accepting SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. -echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses +export ANDROID_HOME=/opt/android-sdk/current +echo "Installing build-tools..." +echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null +echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses > /dev/null echo "INFO: Installing Android SDK packages, including emulator and system image..." sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" From 7b62ea5e05b076a37b4db950139a2e60c7d5785b Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 18:13:48 +0100 Subject: [PATCH 06/32] accept android sdk licenses --- build.sh | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 4162c5c4..11a5a5e0 100755 --- a/build.sh +++ b/build.sh @@ -46,12 +46,45 @@ java -version # Also clear JAVA_HOME variable so java -version is used instead export JAVA_HOME= +# Add the local SDK and emulator tools to the PATH for this session. +# The system-wide Java will already be in the PATH. +export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" +echo "INFO: Local tools added to PATH." + + +# Step 3: Download and set up the Android SDK. +if [ ! -d "$ANDROID_HOME/cmdline-tools" ]; then + echo "INFO: Android SDK not found. Setting it up now..." + + # The URL for the command-line tools can change. + # You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only + CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" + + echo "INFO: Downloading Android command-line tools..." + wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" + + # Unzip into a temporary directory first. + unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip + + # The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest + # The zip extracts to 'cmdline-tools', so we move its contents to the correct location. + mkdir -p "$ANDROID_HOME/cmdline-tools/latest" + mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" + + # Clean up temporary files. + rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip + + echo "INFO: Android command-line tools installed." +else + echo "INFO: Android SDK already found at '$ANDROID_HOME'." +fi + echo "INFO: Accepting SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. export ANDROID_HOME=/opt/android-sdk/current echo "Installing build-tools..." -echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null -echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses > /dev/null +echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null +echo y | sdkmanager --licenses > /dev/null echo "INFO: Installing Android SDK packages, including emulator and system image..." sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" From 8c58d8b5414d4f0c4387698df0eb18377561c54f Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 18:26:11 +0100 Subject: [PATCH 07/32] include android sdk --- build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 11a5a5e0..3b132a29 100755 --- a/build.sh +++ b/build.sh @@ -19,7 +19,7 @@ EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" # Define installation paths for local tools. # These will be created within the project directory. -export ANDROID_HOME="$DIR/android_sdk" +export ANDROID_HOME=/opt/android-sdk/current # --- Environment Setup --- @@ -81,7 +81,7 @@ fi echo "INFO: Accepting SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. -export ANDROID_HOME=/opt/android-sdk/current + echo "Installing build-tools..." echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null echo y | sdkmanager --licenses > /dev/null @@ -98,11 +98,11 @@ chmod +x ./gradlew # Clean the project (optional, but good for a fresh release build) echo "INFO: Cleaning the project..." -./gradlew clean +./gradlew clean -Pandroid.sdk.path=/opt/android-sdk/current # Build the production release bundle without generating a baseline profile. echo "INFO: Building the production release bundle..." -./gradlew app:bundleRelease -x test -Pandroid.baselineProfile.automaticGenerationDuringBuild=false +./gradlew app:bundleRelease -x test -Pandroid.sdk.path=/opt/android-sdk/current # Check if the build was successful if [ $? -eq 0 ]; then From 2796e3c3ca574c4a19019590950aaa02dcf247da Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 18:32:32 +0100 Subject: [PATCH 08/32] include android sdk --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 3b132a29..bf2c1643 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Define the Android SDK version you want to target. ANDROID_SDK_VERSION="36" -ANDROID_BUILD_TOOLS_VERSION="34.0.0" +ANDROID_BUILD_TOOLS_VERSION="35.0.0" # Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). # This system image is designed for headless, automated testing in CI environments @@ -84,10 +84,11 @@ echo "INFO: Accepting SDK licenses..." echo "Installing build-tools..." echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null +echo y | sdkmanager "platforms;android-$ANDROID_SDK_VERSION" > /dev/null echo y | sdkmanager --licenses > /dev/null echo "INFO: Installing Android SDK packages, including emulator and system image..." -sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" +echo y | sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" # --- Build Process --- From 26a442d7cf8773281c36747eb832366b37d0e787 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 18:47:20 +0100 Subject: [PATCH 09/32] include android sdk --- build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index bf2c1643..021c1a50 100755 --- a/build.sh +++ b/build.sh @@ -83,12 +83,12 @@ echo "INFO: Accepting SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. echo "Installing build-tools..." -echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" > /dev/null -echo y | sdkmanager "platforms;android-$ANDROID_SDK_VERSION" > /dev/null -echo y | sdkmanager --licenses > /dev/null +yes | sdkmanager "build-tools;35.0.0" > /dev/null +yes | sdkmanager "platforms;android-36" > /dev/null +yes | sdkmanager --licenses > /dev/null echo "INFO: Installing Android SDK packages, including emulator and system image..." -echo y | sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" +sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" # --- Build Process --- From cff0c19eb2fd93681136174704cd6ff80120cf2f Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 19:21:01 +0100 Subject: [PATCH 10/32] accept licenses --- build.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 021c1a50..6efa7624 100755 --- a/build.sh +++ b/build.sh @@ -79,16 +79,14 @@ else echo "INFO: Android SDK already found at '$ANDROID_HOME'." fi -echo "INFO: Accepting SDK licenses..." +echo "INFO: Accepting all pending SDK licenses..." # The 'yes' command automatically pipes "y" to the license agreement prompts. - -echo "Installing build-tools..." -yes | sdkmanager "build-tools;35.0.0" > /dev/null -yes | sdkmanager "platforms;android-36" > /dev/null -yes | sdkmanager --licenses > /dev/null +yes | sdkmanager --licenses echo "INFO: Installing Android SDK packages, including emulator and system image..." -sdkmanager "platforms;android-$ANDROID_SDK_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platform-tools" "$EMULATOR_IMAGE" "emulator" +# This single command will install/update all necessary packages. +# Ensure ANDROID_SDK_VERSION and ANDROID_BUILD_TOOLS_VERSION are correctly defined earlier in the script. +sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" # --- Build Process --- From dacceff135930e98b8593ee8e3bfa652b52daa32 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 19:34:00 +0100 Subject: [PATCH 11/32] accept licenses --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 6efa7624..eb569056 100755 --- a/build.sh +++ b/build.sh @@ -88,7 +88,7 @@ echo "INFO: Installing Android SDK packages, including emulator and system image # Ensure ANDROID_SDK_VERSION and ANDROID_BUILD_TOOLS_VERSION are correctly defined earlier in the script. sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" - +yes | sdkmanager --licenses # --- Build Process --- # This script assembles the release build of the Android application. From 271e1929fb7f353e353bdfaeae7a03fdd6ba8800 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 19:48:14 +0100 Subject: [PATCH 12/32] accept licenses --- build.sh | 55 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/build.sh b/build.sh index eb569056..3bf309b1 100755 --- a/build.sh +++ b/build.sh @@ -53,42 +53,53 @@ echo "INFO: Local tools added to PATH." # Step 3: Download and set up the Android SDK. -if [ ! -d "$ANDROID_HOME/cmdline-tools" ]; then - echo "INFO: Android SDK not found. Setting it up now..." +# We first remove any old directory to ensure a clean state, which prevents +# errors from inconsistent or pre-existing installations in the CI environment. +if [ -d "$ANDROID_HOME" ]; then + echo "INFO: Found a pre-existing SDK directory. Removing it to ensure a clean build." + # Use sudo as the directory is in /opt + sudo rm -rf "$ANDROID_HOME" +fi - # The URL for the command-line tools can change. - # You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only - CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" +echo "INFO: Android SDK not found or was just removed. Setting it up now..." - echo "INFO: Downloading Android command-line tools..." - wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" +# Create the parent directory with correct permissions before downloading. +sudo mkdir -p "$ANDROID_HOME" - # Unzip into a temporary directory first. - unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip +# The URL for the command-line tools can change. +# You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only +CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" - # The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest - # The zip extracts to 'cmdline-tools', so we move its contents to the correct location. - mkdir -p "$ANDROID_HOME/cmdline-tools/latest" - mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" +echo "INFO: Downloading Android command-line tools..." +wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" - # Clean up temporary files. - rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip +# Unzip into a temporary directory first. +unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip - echo "INFO: Android command-line tools installed." -else - echo "INFO: Android SDK already found at '$ANDROID_HOME'." -fi +# The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest +# The zip extracts to 'cmdline-tools', so we move its contents to the correct location. +mkdir -p "$ANDROID_HOME/cmdline-tools/latest" +mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" + +# Clean up temporary files. +rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip +echo "INFO: Android command-line tools installed." + +# Now, accept licenses and install packages. +# It's best practice to accept licenses *after* the tools are in place. echo "INFO: Accepting all pending SDK licenses..." -# The 'yes' command automatically pipes "y" to the license agreement prompts. yes | sdkmanager --licenses echo "INFO: Installing Android SDK packages, including emulator and system image..." # This single command will install/update all necessary packages. -# Ensure ANDROID_SDK_VERSION and ANDROID_BUILD_TOOLS_VERSION are correctly defined earlier in the script. sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" +# Run license acceptance AGAIN after installing new packages. This is crucial. +echo "INFO: Accepting licenses for newly installed packages..." yes | sdkmanager --licenses + + # --- Build Process --- # This script assembles the release build of the Android application. @@ -105,7 +116,7 @@ echo "INFO: Building the production release bundle..." # Check if the build was successful if [ $? -eq 0 ]; then - echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/prodRelease/" + echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/release/" else echo "FAILURE: Build failed. Please check the console output for errors." exit 1 From 3224defb12b9ec41d0ee86b8a5114532cbf75003 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 28 Jul 2025 19:48:14 +0100 Subject: [PATCH 13/32] Switch to using pre-existing android_home --- build.sh | 47 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/build.sh b/build.sh index eb569056..b0d4fe67 100755 --- a/build.sh +++ b/build.sh @@ -17,11 +17,6 @@ ANDROID_BUILD_TOOLS_VERSION="35.0.0" # be used by the new build command. EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" -# Define installation paths for local tools. -# These will be created within the project directory. -export ANDROID_HOME=/opt/android-sdk/current - - # --- Environment Setup --- # Step 1: Check for essential command-line tools. @@ -51,44 +46,20 @@ export JAVA_HOME= export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" echo "INFO: Local tools added to PATH." - -# Step 3: Download and set up the Android SDK. -if [ ! -d "$ANDROID_HOME/cmdline-tools" ]; then - echo "INFO: Android SDK not found. Setting it up now..." - - # The URL for the command-line tools can change. - # You can find the latest URL at: https://developer.android.com/studio#command-line-tools-only - CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" - - echo "INFO: Downloading Android command-line tools..." - wget -q -O /tmp/cmdline-tools.zip "$CMDLINE_TOOLS_URL" - - # Unzip into a temporary directory first. - unzip -q -d /tmp/android-tmp /tmp/cmdline-tools.zip - - # The SDK manager expects the tools to be in $ANDROID_HOME/cmdline-tools/latest - # The zip extracts to 'cmdline-tools', so we move its contents to the correct location. - mkdir -p "$ANDROID_HOME/cmdline-tools/latest" - mv /tmp/android-tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" - - # Clean up temporary files. - rm -rf /tmp/android-tmp /tmp/cmdline-tools.zip - - echo "INFO: Android command-line tools installed." -else - echo "INFO: Android SDK already found at '$ANDROID_HOME'." -fi - +# Now, accept licenses and install packages. +# It's best practice to accept licenses *after* the tools are in place. echo "INFO: Accepting all pending SDK licenses..." -# The 'yes' command automatically pipes "y" to the license agreement prompts. yes | sdkmanager --licenses echo "INFO: Installing Android SDK packages, including emulator and system image..." # This single command will install/update all necessary packages. -# Ensure ANDROID_SDK_VERSION and ANDROID_BUILD_TOOLS_VERSION are correctly defined earlier in the script. sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" +# Run license acceptance AGAIN after installing new packages. This is crucial. +echo "INFO: Accepting licenses for newly installed packages..." yes | sdkmanager --licenses + + # --- Build Process --- # This script assembles the release build of the Android application. @@ -97,15 +68,15 @@ chmod +x ./gradlew # Clean the project (optional, but good for a fresh release build) echo "INFO: Cleaning the project..." -./gradlew clean -Pandroid.sdk.path=/opt/android-sdk/current +./gradlew clean -Pandroid.sdk.path=$ANDROID_HOME # Build the production release bundle without generating a baseline profile. echo "INFO: Building the production release bundle..." -./gradlew app:bundleRelease -x test -Pandroid.sdk.path=/opt/android-sdk/current +./gradlew app:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME # Check if the build was successful if [ $? -eq 0 ]; then - echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/prodRelease/" + echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/release/" else echo "FAILURE: Build failed. Please check the console output for errors." exit 1 From e645fbec59dea9fd74ef226778bb7ab33359e15f Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Wed, 30 Jul 2025 13:44:16 +0100 Subject: [PATCH 14/32] Change presubmit to use debug app services json --- build_presubmit.sh | 86 +++++++++++++++++++ .../kokoro_presubmit_build.sh | 19 ++++ kokoro/gcp_ubuntu_docker/presubmit.cfg | 2 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 build_presubmit.sh create mode 100644 kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh diff --git a/build_presubmit.sh b/build_presubmit.sh new file mode 100644 index 00000000..4cae8176 --- /dev/null +++ b/build_presubmit.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Fail on any error to ensure the script stops if a step fails. +set -e + +# --- Configuration --- +# Get the script's directory. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Define the Android SDK version you want to target. +ANDROID_SDK_VERSION="36" +ANDROID_BUILD_TOOLS_VERSION="35.0.0" + +# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). +# This system image is designed for headless, automated testing in CI environments +# and is more compatible with software rendering. It will be installed but may not +# be used by the new build command. +EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" + +# --- Environment Setup --- + +# Step 1: Check for essential command-line tools. +echo "INFO: Checking for prerequisites (wget, unzip, tar)..." +for cmd in wget unzip tar; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: Command '$cmd' not found. Please install it using your system's package manager (e.g., 'sudo apt-get install $cmd') and try again." + exit 1 + fi +done +echo "INFO: Prerequisites are installed." + + +# Step 2: Install and configure Java 17 system-wide. +echo "INFO: Setting up Java 17..." +# The build needs Java 17, set it as the default Java version. +sudo apt-get update +sudo apt-get install -y openjdk-17-jdk +sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java +java -version + +# Also clear JAVA_HOME variable so java -version is used instead +export JAVA_HOME= + +# Add the local SDK and emulator tools to the PATH for this session. +# The system-wide Java will already be in the PATH. +export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" +echo "INFO: Local tools added to PATH." + +# Now, accept licenses and install packages. +# It's best practice to accept licenses *after* the tools are in place. +echo "INFO: Accepting all pending SDK licenses..." +yes | sdkmanager --licenses + +echo "INFO: Installing Android SDK packages, including emulator and system image..." +# This single command will install/update all necessary packages. +sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" + +# Run license acceptance AGAIN after installing new packages. This is crucial. +echo "INFO: Accepting licenses for newly installed packages..." +yes | sdkmanager --licenses + + +# --- Build Process --- + +# This script assembles the release build of the Android application. +# Ensure gradlew is executable +chmod +x ./gradlew + +# Clean the project (optional, but good for a fresh release build) +echo "INFO: Cleaning the project..." +./gradlew clean -Pandroid.sdk.path=$ANDROID_HOME +# Load up test google-services.json +cp test-google-services.json app/google-services.json +# Build the production release bundle without generating a baseline profile. +echo "INFO: Building the production release bundle..." +./gradlew app:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/release/" +else + echo "FAILURE: Build failed. Please check the console output for errors." + exit 1 +fi + +exit 0 diff --git a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh new file mode 100644 index 00000000..723b286a --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Fail on any error. +set -e + +# Display commands being run. +# WARNING: please only enable 'set -x' if necessary for debugging, and be very +# careful if you handle credentials (e.g. from Keystore) with 'set -x': +# statements like "export VAR=$(cat /tmp/keystore/credentials)" will result in +# the credentials being printed in build logs. +# Additionally, recursive invocation with credentials as command-line +# parameters, will print the full command, with credentials, in the build logs. +# set -x + +# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/github. +# The final directory name in this path is determined by the scm name specified +# in the job configuration. +cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" +./build_presubmit.sh \ No newline at end of file diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index d9f93353..0cef8401 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -1 +1 @@ -build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" \ No newline at end of file +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" \ No newline at end of file From 2d4514050ea79f67781e01efd4a38e7a0ec7731d Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Wed, 30 Jul 2025 13:53:31 +0100 Subject: [PATCH 15/32] Change file permissions --- build_presubmit.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build_presubmit.sh diff --git a/build_presubmit.sh b/build_presubmit.sh old mode 100644 new mode 100755 From 6bed277a81a72f68f7d2aadea246933265b5749a Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Wed, 30 Jul 2025 14:09:21 +0100 Subject: [PATCH 16/32] Dont do crashlytics upload for presubmit release --- build_presubmit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_presubmit.sh b/build_presubmit.sh index 4cae8176..ca9e161b 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -73,7 +73,7 @@ echo "INFO: Cleaning the project..." cp test-google-services.json app/google-services.json # Build the production release bundle without generating a baseline profile. echo "INFO: Building the production release bundle..." -./gradlew app:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME +./gradlew app:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME # Check if the build was successful if [ $? -eq 0 ]; then From adafdd6dc4ec417774670c131774633f1d54dbe9 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Wed, 30 Jul 2025 14:28:13 +0100 Subject: [PATCH 17/32] add artifact storage --- kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh index 723b286a..893cc37a 100644 --- a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh +++ b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh @@ -16,4 +16,11 @@ set -e # The final directory name in this path is determined by the scm name specified # in the job configuration. cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" -./build_presubmit.sh \ No newline at end of file +./build_presubmit.sh + +# Create the target directory in KOKORO_ARTIFACTS_DIR if it doesn't exist. +ARTIFACT_DIR="$KOKORO_ARTIFACTS_DIR/app-bundles" +mkdir -p "$ARTIFACT_DIR" + +# Copy all .aab files to the KOKORO_ARTIFACTS_DIR. +cp app/build/outputs/bundle/release/*.aab "$ARTIFACT_DIR" \ No newline at end of file From 41a3a6f55c832100c2c475dc50b20e12e857b0c7 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Thu, 31 Jul 2025 13:52:27 +0100 Subject: [PATCH 18/32] Copy from prebuilts --- build.sh | 6 ++++++ build_presubmit.sh | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index b0d4fe67..896974d5 100755 --- a/build.sh +++ b/build.sh @@ -59,6 +59,12 @@ sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUI echo "INFO: Accepting licenses for newly installed packages..." yes | sdkmanager --licenses +echo "Copying google-services.json" +cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app + +echo "Copying local.properties" +cp /tmpfs/src/git/androidify-prebuilts/gradle.properties ${DIR} +ls # --- Build Process --- diff --git a/build_presubmit.sh b/build_presubmit.sh index ca9e161b..1cafb190 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -6,7 +6,7 @@ set -e # --- Configuration --- # Get the script's directory. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - +echo DIR # Define the Android SDK version you want to target. ANDROID_SDK_VERSION="36" ANDROID_BUILD_TOOLS_VERSION="35.0.0" @@ -59,6 +59,12 @@ sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUI echo "INFO: Accepting licenses for newly installed packages..." yes | sdkmanager --licenses +echo "Copying google-services.json" +cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app + +echo "Copying local.properties" +cp /tmpfs/src/git/androidify-prebuilts/gradle.properties ${DIR} +ls # --- Build Process --- @@ -69,8 +75,7 @@ chmod +x ./gradlew # Clean the project (optional, but good for a fresh release build) echo "INFO: Cleaning the project..." ./gradlew clean -Pandroid.sdk.path=$ANDROID_HOME -# Load up test google-services.json -cp test-google-services.json app/google-services.json + # Build the production release bundle without generating a baseline profile. echo "INFO: Building the production release bundle..." ./gradlew app:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME From 20eaa45c35020d56406ea03478e7833b2d77d708 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 1 Aug 2025 10:16:03 +0100 Subject: [PATCH 19/32] Concatenate the gradle.properties file --- build_presubmit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_presubmit.sh b/build_presubmit.sh index 1cafb190..f3b2240c 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -63,7 +63,7 @@ echo "Copying google-services.json" cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app echo "Copying local.properties" -cp /tmpfs/src/git/androidify-prebuilts/gradle.properties ${DIR} +cat /tmpfs/src/git/androidify-prebuilts/gradle.properties >> ${DIR}/gradle.properties ls # --- Build Process --- From e134283144a738984bc12df6d47a22c120c9959c Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 1 Aug 2025 10:30:12 +0100 Subject: [PATCH 20/32] Concatenate the gradle.properties file --- build_presubmit.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_presubmit.sh b/build_presubmit.sh index f3b2240c..328b6a10 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -62,7 +62,8 @@ yes | sdkmanager --licenses echo "Copying google-services.json" cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app -echo "Copying local.properties" +echo "Copying gradle.properties" +echo "" >> ${DIR}/gradle.properties # add a new line to the file cat /tmpfs/src/git/androidify-prebuilts/gradle.properties >> ${DIR}/gradle.properties ls From a4ebd78e4d850a0584d03358c4de0540cee48f12 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 1 Aug 2025 11:04:35 +0100 Subject: [PATCH 21/32] copy unsigned aab --- build.sh | 6 ++--- build_presubmit.sh | 23 +++++++++++++++++++ .../kokoro_presubmit_build.sh | 7 ------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 896974d5..6f5c94c1 100755 --- a/build.sh +++ b/build.sh @@ -62,9 +62,9 @@ yes | sdkmanager --licenses echo "Copying google-services.json" cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app -echo "Copying local.properties" -cp /tmpfs/src/git/androidify-prebuilts/gradle.properties ${DIR} -ls +echo "Copying gradle.properties" +echo "" >> ${DIR}/gradle.properties # add a new line to the file +cat /tmpfs/src/git/androidify-prebuilts/gradle.properties >> ${DIR}/gradle.properties # --- Build Process --- diff --git a/build_presubmit.sh b/build_presubmit.sh index 328b6a10..237152eb 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -88,5 +88,28 @@ else echo "FAILURE: Build failed. Please check the console output for errors." exit 1 fi +# --- Artifact Collection --- +echo "INFO: Preparing artifacts for Kokoro..." + +# Default output path for the bundle +AAB_SRC_DIR="app/build/outputs/bundle/release" +# The default name of the AAB for a release bundle +AAB_FILE="app-release.aab" +AAB_PATH="${AAB_SRC_DIR}/${AAB_FILE}" + +# Check if the AAB exists +if [[ -f "$AAB_PATH" ]]; then + # Create a directory within Kokoro's artifact collection area + ARTIFACT_DEST_DIR="${KOKORO_ARTIFACTS_DIR}/artifacts" + mkdir -p "${ARTIFACT_DEST_DIR}" + + # Copy the AAB + cp "${AAB_PATH}" "${ARTIFACT_DEST_DIR}/app-release-unsigned.aab" + echo "SUCCESS: AAB copied to ${ARTIFACT_DEST_DIR}" + +else + echo "FAILURE: AAB not found at ${AAB_PATH}" + # Optionally fail the build: exit 1 +fi exit 0 diff --git a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh index 893cc37a..05e0bdd6 100644 --- a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh +++ b/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh @@ -17,10 +17,3 @@ set -e # in the job configuration. cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" ./build_presubmit.sh - -# Create the target directory in KOKORO_ARTIFACTS_DIR if it doesn't exist. -ARTIFACT_DIR="$KOKORO_ARTIFACTS_DIR/app-bundles" -mkdir -p "$ARTIFACT_DIR" - -# Copy all .aab files to the KOKORO_ARTIFACTS_DIR. -cp app/build/outputs/bundle/release/*.aab "$ARTIFACT_DIR" \ No newline at end of file From 595193aabcf46ef10d65d8331b2b1e5118d84fe6 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 1 Aug 2025 11:08:18 +0100 Subject: [PATCH 22/32] add build action to define artifacts --- kokoro/gcp_ubuntu_docker/continuous.cfg | 11 ++++++++++- kokoro/gcp_ubuntu_docker/presubmit.cfg | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/kokoro/gcp_ubuntu_docker/continuous.cfg b/kokoro/gcp_ubuntu_docker/continuous.cfg index d9f93353..c6c9f143 100644 --- a/kokoro/gcp_ubuntu_docker/continuous.cfg +++ b/kokoro/gcp_ubuntu_docker/continuous.cfg @@ -1 +1,10 @@ -build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" \ No newline at end of file +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" + +action { + define_artifacts { + regex: "artifacts/*_unsigned.aab" + + # Optional: Removes the "artifacts/" part from the path in the artifact storage + strip_prefix: "artifacts" + } +} \ No newline at end of file diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index 0cef8401..df29ed25 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -1 +1,10 @@ -build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" \ No newline at end of file +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" + +action { + define_artifacts { + regex: "artifacts/*_unsigned.aab" + + # Optional: Removes the "artifacts/" part from the path in the artifact storage + strip_prefix: "artifacts" + } +} \ No newline at end of file From 0e35c5df055fceca8d04db94a408e5114c1b7228 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 1 Aug 2025 15:54:56 +0100 Subject: [PATCH 23/32] add fail_if_no_artifacts = true. --- kokoro/gcp_ubuntu_docker/continuous.cfg | 5 +++-- kokoro/gcp_ubuntu_docker/presubmit.cfg | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kokoro/gcp_ubuntu_docker/continuous.cfg b/kokoro/gcp_ubuntu_docker/continuous.cfg index c6c9f143..22e12df0 100644 --- a/kokoro/gcp_ubuntu_docker/continuous.cfg +++ b/kokoro/gcp_ubuntu_docker/continuous.cfg @@ -2,9 +2,10 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" action { define_artifacts { - regex: "artifacts/*_unsigned.aab" + regex: "artifacts/**.aab" # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" + fail_if_no_artifacts: true } -} \ No newline at end of file +} diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index df29ed25..4ea7325d 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -2,9 +2,10 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" action { define_artifacts { - regex: "artifacts/*_unsigned.aab" + regex: "artifacts/**.aab" # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" + fail_if_no_artifacts: true } } \ No newline at end of file From 1e0b11f0f95cbcae24e7962ffccee10c3ed10aa7 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 10:13:24 +0100 Subject: [PATCH 24/32] Store attestation too --- kokoro/gcp_ubuntu_docker/presubmit.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index 4ea7325d..8ef2aa62 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -3,9 +3,11 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" action { define_artifacts { regex: "artifacts/**.aab" + regex: "**.intoto.jsonl" # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" fail_if_no_artifacts: true + store_attestation: true } -} \ No newline at end of file +} From eb965c7aa6c99fa43b8c0938f08b987f80d3e2ae Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 10:29:00 +0100 Subject: [PATCH 25/32] Remove unsupported tag --- kokoro/gcp_ubuntu_docker/presubmit.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index 8ef2aa62..78376c2b 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -8,6 +8,5 @@ action { # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" fail_if_no_artifacts: true - store_attestation: true } } From aad7ef167bf8590b70820253314ec04b6d68da3a Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 10:47:55 +0100 Subject: [PATCH 26/32] copy .intointo.jsonl file into output folder --- build_presubmit.sh | 5 +++++ kokoro/gcp_ubuntu_docker/presubmit.cfg | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build_presubmit.sh b/build_presubmit.sh index 237152eb..4f15c653 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -107,6 +107,11 @@ if [[ -f "$AAB_PATH" ]]; then cp "${AAB_PATH}" "${ARTIFACT_DEST_DIR}/app-release-unsigned.aab" echo "SUCCESS: AAB copied to ${ARTIFACT_DEST_DIR}" + # Copy any .intointo.jsonl files to the artifact directory + echo "INFO: Searching for and copying .intointo.jsonl files..." + find . -type f -name "*.intointo.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/" + echo "INFO: Finished copying .intointo.jsonl files." + else echo "FAILURE: AAB not found at ${AAB_PATH}" # Optionally fail the build: exit 1 diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index 78376c2b..b7c1edbe 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -3,7 +3,7 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" action { define_artifacts { regex: "artifacts/**.aab" - regex: "**.intoto.jsonl" + regex: "artifacts/**.intoto.jsonl" # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" From 046c6b235523502665bab386c0a6cee23856bd04 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 11:08:09 +0100 Subject: [PATCH 27/32] Log contents of folders. --- build_presubmit.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_presubmit.sh b/build_presubmit.sh index 4f15c653..4df164aa 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -109,6 +109,9 @@ if [[ -f "$AAB_PATH" ]]; then # Copy any .intointo.jsonl files to the artifact directory echo "INFO: Searching for and copying .intointo.jsonl files..." + ls + echo "INFO: Logging output directory contents" + ls "$AAB_SRC_DIR/" find . -type f -name "*.intointo.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/" echo "INFO: Finished copying .intointo.jsonl files." From 90fb1ea62866719f10e22b7f19413a69cbcb183e Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 11:12:40 +0100 Subject: [PATCH 28/32] Change build.sh file to mirror presubmit --- build.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/build.sh b/build.sh index 6f5c94c1..fc8670be 100755 --- a/build.sh +++ b/build.sh @@ -87,5 +87,36 @@ else echo "FAILURE: Build failed. Please check the console output for errors." exit 1 fi +# --- Artifact Collection --- +echo "INFO: Preparing artifacts for Kokoro..." + +# Default output path for the bundle +AAB_SRC_DIR="app/build/outputs/bundle/release" +# The default name of the AAB for a release bundle +AAB_FILE="app-release.aab" +AAB_PATH="${AAB_SRC_DIR}/${AAB_FILE}" + +# Check if the AAB exists +if [[ -f "$AAB_PATH" ]]; then + # Create a directory within Kokoro's artifact collection area + ARTIFACT_DEST_DIR="${KOKORO_ARTIFACTS_DIR}/artifacts" + mkdir -p "${ARTIFACT_DEST_DIR}" + + # Copy the AAB + cp "${AAB_PATH}" "${ARTIFACT_DEST_DIR}/app-release-unsigned.aab" + echo "SUCCESS: AAB copied to ${ARTIFACT_DEST_DIR}" + + # Copy any .intointo.jsonl files to the artifact directory + echo "INFO: Searching for and copying .intointo.jsonl files..." + ls + echo "INFO: Logging output directory contents" + ls "$AAB_SRC_DIR/" + find . -type f -name "*.intointo.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/" + echo "INFO: Finished copying .intointo.jsonl files." + +else + echo "FAILURE: AAB not found at ${AAB_PATH}" + # Optionally fail the build: exit 1 +fi exit 0 From 980e970391ea0da7761517fe56518ccec8595db4 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 11:18:23 +0100 Subject: [PATCH 29/32] Add .intointo.jsonl for continuous.cfg --- kokoro/gcp_ubuntu_docker/continuous.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kokoro/gcp_ubuntu_docker/continuous.cfg b/kokoro/gcp_ubuntu_docker/continuous.cfg index 22e12df0..ab1a880a 100644 --- a/kokoro/gcp_ubuntu_docker/continuous.cfg +++ b/kokoro/gcp_ubuntu_docker/continuous.cfg @@ -3,7 +3,7 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" action { define_artifacts { regex: "artifacts/**.aab" - + regex: "artifacts/**.intoto.jsonl" # Optional: Removes the "artifacts/" part from the path in the artifact storage strip_prefix: "artifacts" fail_if_no_artifacts: true From 176bb90aa462c3ef540cafef1b94f36f67acd283 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 12:04:57 +0100 Subject: [PATCH 30/32] Add release.cfg --- kokoro/gcp_ubuntu_docker/release.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 kokoro/gcp_ubuntu_docker/release.cfg diff --git a/kokoro/gcp_ubuntu_docker/release.cfg b/kokoro/gcp_ubuntu_docker/release.cfg new file mode 100644 index 00000000..018d337d --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/release.cfg @@ -0,0 +1,12 @@ +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" + +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + + # Optional: Removes the "artifacts/" part from the path in the artifact storage + strip_prefix: "artifacts" + fail_if_no_artifacts: true + } +} From 67be63358a9839b67b52e307032b71a91a4a44a7 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 12:44:43 +0100 Subject: [PATCH 31/32] Add back headers and remove unnessecary bits of script, upgrade to newer tools --- build.sh | 29 +++++++++++++++++++---------- build_presubmit.sh | 29 +++++++++++++++++++---------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index fc8670be..a03881dc 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,21 @@ #!/usr/bin/env bash - +# +# Copyright 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# IGNORE this file, it's only used in the internal Google release process # Fail on any error to ensure the script stops if a step fails. set -e @@ -9,13 +25,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Define the Android SDK version you want to target. ANDROID_SDK_VERSION="36" -ANDROID_BUILD_TOOLS_VERSION="35.0.0" +ANDROID_BUILD_TOOLS_VERSION="36.0.0" # Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). # This system image is designed for headless, automated testing in CI environments # and is more compatible with software rendering. It will be installed but may not # be used by the new build command. -EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" +EMULATOR_IMAGE="system-images;android-36;google_atd;x86_64" # --- Environment Setup --- @@ -80,13 +96,6 @@ echo "INFO: Cleaning the project..." echo "INFO: Building the production release bundle..." ./gradlew app:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -# Check if the build was successful -if [ $? -eq 0 ]; then - echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/release/" -else - echo "FAILURE: Build failed. Please check the console output for errors." - exit 1 -fi # --- Artifact Collection --- echo "INFO: Preparing artifacts for Kokoro..." diff --git a/build_presubmit.sh b/build_presubmit.sh index 4df164aa..4347bc98 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -1,5 +1,21 @@ #!/usr/bin/env bash - +# +# Copyright 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# IGNORE this file, it's only used in the internal Google release process # Fail on any error to ensure the script stops if a step fails. set -e @@ -9,13 +25,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo DIR # Define the Android SDK version you want to target. ANDROID_SDK_VERSION="36" -ANDROID_BUILD_TOOLS_VERSION="35.0.0" +ANDROID_BUILD_TOOLS_VERSION="36.0.0" # Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). # This system image is designed for headless, automated testing in CI environments # and is more compatible with software rendering. It will be installed but may not # be used by the new build command. -EMULATOR_IMAGE="system-images;android-34;google_atd;x86_64" +EMULATOR_IMAGE="system-images;android-36;google_atd;x86_64" # --- Environment Setup --- @@ -81,13 +97,6 @@ echo "INFO: Cleaning the project..." echo "INFO: Building the production release bundle..." ./gradlew app:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -# Check if the build was successful -if [ $? -eq 0 ]; then - echo "SUCCESS: Build successful! The AAB can be found in app/build/outputs/bundle/release/" -else - echo "FAILURE: Build failed. Please check the console output for errors." - exit 1 -fi # --- Artifact Collection --- echo "INFO: Preparing artifacts for Kokoro..." From b74b7df534f8ebf6f23f035a0e28e1aa4fe6f3bb Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 4 Aug 2025 12:53:09 +0100 Subject: [PATCH 32/32] Add notes about 36 availability for google_atd --- build.sh | 3 ++- build_presubmit.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index a03881dc..424adedc 100755 --- a/build.sh +++ b/build.sh @@ -31,7 +31,8 @@ ANDROID_BUILD_TOOLS_VERSION="36.0.0" # This system image is designed for headless, automated testing in CI environments # and is more compatible with software rendering. It will be installed but may not # be used by the new build command. -EMULATOR_IMAGE="system-images;android-36;google_atd;x86_64" +# 36 not available yet as per b/432143095 +EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64" # --- Environment Setup --- diff --git a/build_presubmit.sh b/build_presubmit.sh index 4347bc98..372a7956 100755 --- a/build_presubmit.sh +++ b/build_presubmit.sh @@ -31,7 +31,8 @@ ANDROID_BUILD_TOOLS_VERSION="36.0.0" # This system image is designed for headless, automated testing in CI environments # and is more compatible with software rendering. It will be installed but may not # be used by the new build command. -EMULATOR_IMAGE="system-images;android-36;google_atd;x86_64" +# 36 not available yet as per b/432143095 +EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64" # --- Environment Setup ---