Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8838daa
Code review comments.
riggaroo Jul 28, 2025
a467a3a
Fix presubmit to androidify build
riggaroo Jul 28, 2025
7e50eb6
Fix presubmit to androidify build
riggaroo Jul 28, 2025
f0838b6
accept android sdk licenses
riggaroo Jul 28, 2025
3c4124e
accept android sdk licenses
riggaroo Jul 28, 2025
7b62ea5
accept android sdk licenses
riggaroo Jul 28, 2025
8c58d8b
include android sdk
riggaroo Jul 28, 2025
2796e3c
include android sdk
riggaroo Jul 28, 2025
26a442d
include android sdk
riggaroo Jul 28, 2025
cff0c19
accept licenses
riggaroo Jul 28, 2025
dacceff
accept licenses
riggaroo Jul 28, 2025
271e192
accept licenses
riggaroo Jul 28, 2025
3224def
Switch to using pre-existing android_home
riggaroo Jul 28, 2025
724afd9
Merge branch 'feature/kokoro' of https://github.com/android/androidif…
riggaroo Jul 28, 2025
e645fbe
Change presubmit to use debug app services json
riggaroo Jul 30, 2025
2d45140
Change file permissions
riggaroo Jul 30, 2025
6bed277
Dont do crashlytics upload for presubmit release
riggaroo Jul 30, 2025
adafdd6
add artifact storage
riggaroo Jul 30, 2025
41a3a6f
Copy from prebuilts
riggaroo Jul 31, 2025
20eaa45
Concatenate the gradle.properties file
riggaroo Aug 1, 2025
e134283
Concatenate the gradle.properties file
riggaroo Aug 1, 2025
a4ebd78
copy unsigned aab
riggaroo Aug 1, 2025
595193a
add build action to define artifacts
riggaroo Aug 1, 2025
0e35c5d
add fail_if_no_artifacts = true.
riggaroo Aug 1, 2025
1e0b11f
Store attestation too
riggaroo Aug 4, 2025
eb965c7
Remove unsupported tag
riggaroo Aug 4, 2025
aad7ef1
copy .intointo.jsonl file into output folder
riggaroo Aug 4, 2025
046c6b2
Log contents of folders.
riggaroo Aug 4, 2025
90fb1ea
Change build.sh file to mirror presubmit
riggaroo Aug 4, 2025
980e970
Add .intointo.jsonl for continuous.cfg
riggaroo Aug 4, 2025
176bb90
Add release.cfg
riggaroo Aug 4, 2025
67be633
Add back headers and remove unnessecary bits of script, upgrade to ne…
riggaroo Aug 4, 2025
b74b7df
Add notes about 36 availability for google_atd
riggaroo Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
baselineProfile.automaticGenerationDuringBuild = true
baselineProfile.automaticGenerationDuringBuild = false
configure<CrashlyticsExtension> {
mappingFileUploadEnabled = true
}
Expand Down
116 changes: 101 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

#
# Copyright 2022 The Android Open Source Project
# 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.
Expand All @@ -17,30 +16,117 @@
#

# 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="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.
# 36 not available yet as per b/432143095
EMULATOR_IMAGE="system-images;android-35;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

echo "Copying google-services.json"
cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app

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 ---

# 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..."
./gradlew clean
echo "INFO: Cleaning the project..."
./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=$ANDROID_HOME

# --- 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}"

# Assemble the release build
echo "Assembling the release build..."
./gradlew app:bundleRelease
# 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."

# Check if the build was successful
if [ $? -eq 0 ]; then
echo "Build successful! The APK/AAB can be found in app/build/outputs/"
else
echo "Build failed. Please check the console output for errors."
exit 1
echo "FAILURE: AAB not found at ${AAB_PATH}"
# Optionally fail the build: exit 1
fi

exit 0
exit 0
133 changes: 133 additions & 0 deletions build_presubmit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/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

# --- 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="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.
# 36 not available yet as per b/432143095
EMULATOR_IMAGE="system-images;android-35;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

echo "Copying google-services.json"
cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app

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

# --- 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

# 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

# --- 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
12 changes: 11 additions & 1 deletion kokoro/gcp_ubuntu_docker/continuous.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh"
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
}
}
19 changes: 19 additions & 0 deletions kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion kokoro/gcp_ubuntu_docker/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
build_file: "kokoro-codelab-riggaroo/kokoro/gcp_ubuntu_docker/kokoro_build.sh"
build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_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
}
}
12 changes: 12 additions & 0 deletions kokoro/gcp_ubuntu_docker/release.cfg
Original file line number Diff line number Diff line change
@@ -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
}
}